Search the web
Sign In
New User? Sign Up
ace-users
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
[ace-users] Re: Stateful server   Message List  
Reply | Forward Message #30978 of 42992 |
Hi Vlad,

>> Is that possible to implement something like a stateful web-server
>> with ACE?

Sure.

>> Its work could be described the following way:
>>
>> - As long as a thread-pool there is a pool of allocated handler objects,
>> which could be spare or used.
>> - Spare handler objects lie somewhere in memory, used ones do their work
>> in threads - one thread per one object.

Right.

>> - Acceptor waits for a connection on the specified TCP port or unix socket.
>> - When a connection arrives, Acceptor uses programmer-redefined routine
>> to check its conformity to one of the spare Handler objects.

Right, you could do this as follows:

1. Derive a class from ACE_Acceptor called something like Cached_Acceptor
2. Make the Cached_Acceptor::make_svc_handler() hook method a no-op
3. Make the Cached_Acceptor::accept_svc_handler() hook method do the
following:

>> If the conformity could not be found, the request is considered
>> "general". The conformity is usually checked by looking into the
>> data received from client.
>> - Once the conformity is found, the appropriate Handler object becomes
>> "used", and its handle_input() is called in a separate thread. If
>> there're no spare threads at the moment, an error message is returned to
>> the client.

>> - Object's handle_input() deals with the request. After that the object
>> isn't destroyed, but becomes spare again. Its thread therefore also
>> becomes spare.
>>
>> - Spare object are destroyed after a request timeout.

You can use ACE_Reactor::schedule_timer() and
ACE_Reactor::cancel_timer() to do this.

>> - There're also "general" handler objects, which are never destroyed, and
>> they handle "general" requests.
>>
>> I couldn't find the description of such a behaivor in ACE docs. But
>> implementing all this from scratch looks like reinventing the wheel.

It should be pretty trivial to do this with ACE_Acceptor.

Take care,

Doug
--
Dr. Douglas C. Schmidt, Associate Professor TEL: (949) 824-1901
Dept of Electrical & Computer Engineering FAX: (949) 824-2321
616E Engineering Tower WEB: www.ece.uci.edu/~schmidt/
University of California, Irvine, 92697-2625 NET: schmidt@...



Wed May 15, 2002 4:03 pm

schmidt@...
Send Email Send Email

Forward
Message #30978 of 42992 |
Expand Messages Author Sort by Date

Hi Vlad, ... Sure. ... Right. ... Right, you could do this as follows: 1. Derive a class from ACE_Acceptor called something like Cached_Acceptor 2. Make the...
Douglas C. Schmidt
schmidt@...
Send Email
May 15, 2002
4:04 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help