Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost-users][asio] timeout -isio_service.reset()safe with pool of threads?
From: tomasz jankowski (tomasz_jacek_at_[hidden])
Date: 2009-02-03 03:59:00


Dnia 2-02-2009 o godz. 12:33 Igor R napisał(a):
Exaclty. If you look at other asio examples you'll see the same pattern: async. operations are chained in the way that completion handler of a previous operation launches the next one. This pattern allows you to end the i/o in a very simple way: just break the above chain and the io_service.run() ends. Note also that if your handlers are made of some "connection" object (using shared_from_this, like in the examples) that encapsulates socket, then when the chain terminates, this object is automatically destroyed closing its socket.


I have understood it  yesterday evening when I read about boos.shared_ptr but I still don't understand why connection object must be noncopyable...


However, such a simple design is not always possible. In more complicated cases you have to keep io_service running *always*, even when there's no i/o activity - until explicitly stopped. Refer to the following example to see how you can do this:
http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/example/http/server2/io_service_pool.cpp 
 

I don't understand how it works :(. we have few io_service object which are run() in separated threads. but only one is maintained by async_accept chain trick. the rest run() should immediately return.

 
> you're welcome :)

thanks :)

tom




----------------------------------------------------
Nużą Cię utarte scenariusze?
Wymyśl własną grę flashową i wygraj główną nagrodę 5.000 Euro:
http://klik.wp.pl/?adr=http://whosegame.pl/contestcard.php?contest=55&sid=631

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net