[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Thinking About GServer

James Gray

11/19/2004 12:06:00 AM

I need to code up a server. It could have as many as fifty
simultaneous users all sending in commands. Those commands need to be
processed in the order received, and many logged-in users may see
changes based on the processing of those commands.

I can code all this myself, I'm sure, but I thought I would have a look
at GServer. It looks to simplify server setup and incoming reads, but
it doesn't seem to offer any help for output. Am I reading this right?

My plan for handling input is to push all commands onto a thread safe
queue and have the main event thread pull them off the other end one at
a time. But let's say that an event affects users A, B, and C. How do
I notify them all?

Do I cache their sockets when they log in, by name, and then write to
each of those when the time comes? Those writes would need to be
threaded I suppose, to avoid blocking the event thread.

I guess mainly what I'm asking is, I need to roll all this output
handling on top of GServer, if I want to use it, right?

Thanks.

James Edward Gray II



4 Answers

Joel VanderWerf

11/19/2004 12:40:00 AM

0

James Edward Gray II wrote:
> I need to code up a server. It could have as many as fifty simultaneous
> users all sending in commands. Those commands need to be processed in
> the order received, and many logged-in users may see changes based on
> the processing of those commands.
>
> I can code all this myself, I'm sure, but I thought I would have a look
> at GServer. It looks to simplify server setup and incoming reads, but
> it doesn't seem to offer any help for output. Am I reading this right?
>
> My plan for handling input is to push all commands onto a thread safe
> queue and have the main event thread pull them off the other end one at
> a time. But let's say that an event affects users A, B, and C. How do
> I notify them all?
>
> Do I cache their sockets when they log in, by name, and then write to
> each of those when the time comes? Those writes would need to be
> threaded I suppose, to avoid blocking the event thread.
>
> I guess mainly what I'm asking is, I need to roll all this output
> handling on top of GServer, if I want to use it, right?

Have you considered, at least for prototyping, using drb, with the
thread-safe queue being the object exposed to clients (i.e.,
DRbUndumped) by drb? The client code would push commands onto this
queue, and the server would pull them off. The command object could
contain a reference to a DRbUndumped object that stays on the client
side. The server calls methods on this object to notify the client.
(Another approach is to use yield: the client provides a block, and the
server yields to it, passing a notification value.)

For 50 clients, this might be less responsive than using GServer, though.


James Gray

11/19/2004 12:53:00 AM

0

On Nov 18, 2004, at 6:39 PM, Joel VanderWerf wrote:

> Have you considered, at least for prototyping, using drb, with the
> thread-safe queue being the object exposed to clients (i.e.,
> DRbUndumped) by drb?

I should have specified this in my original message, my bad. My server
needs to be reachable with simple Telnet.

James Edward Gray II



Shashank Date

11/19/2004 2:44:00 AM

0

Hi James,

--- James Edward Gray II <james@grayproductions.net>
wrote:

> My plan for handling input is to push all commands
> onto a thread safe
> queue and have the main event thread pull them off
> the other end one at
> a time. But let's say that an event affects users
> A, B, and C. How do
> I notify them all?

I may not be reading this right (ignorant me ;-) but
it sounds something like Ara Howard's rq package:

http://raa.ruby-lang.org/p...

Again, apologies if that is not you meant.

> James Edward Gray II

-- shanko
>
>




__________________________________
Do you Yahoo!?
The all-new My Yahoo! - Get yours free!
http://my...




Joel VanderWerf

11/19/2004 3:28:00 AM

0

Shashank Date wrote:
> Hi James,
>
> --- James Edward Gray II <james@grayproductions.net>
> wrote:
>
>
>>My plan for handling input is to push all commands
>>onto a thread safe
>>queue and have the main event thread pull them off
>>the other end one at
>>a time. But let's say that an event affects users
>>A, B, and C. How do
>>I notify them all?
>
>
> I may not be reading this right (ignorant me ;-) but
> it sounds something like Ara Howard's rq package:
>
> http://raa.ruby-lang.org/p...

I think that requires all processes to access the queue on an nfs share.