Re: [asio-users] Monitoring thread liveness using multiple threads witha single asio io_service
Brought to you by:
chris_kohlhoff
From: Gruenke, M. <mgruenke@Tycoint.com> - 2011-04-14 01:52:44
|
Oh, and you could use async_wait() to ensure that events arrive at some minimum frequency. Matt ________________________________ From: Gruenke, Matt Sent: Wed 4/13/2011 9:49 PM To: asi...@li... Subject: RE: [asio-users] Monitoring thread liveness using multiple threads witha single asio io_service I think the distribution of work would be usage dependent. Maybe there are patterns in your events that result in one thread being particularly burdened? I think your solution looks good. What's the problem - too frequent heartbeats from some threads? I'd either maintain a timestamp of the last heartbeat, and only send one if at least a certain amount of time has elapsed, or replace the heartbeat with an update of a timestamp indicating the last time the thread iterated the loop. In the second case, either something else can watch those timestamps or perhaps each thread can check both its own and all other threads timestamps to periodically send indications of thread activity. Matt ________________________________ From: Krajnak, Mike (GE Healthcare) [mailto:mic...@me...] Sent: Wed 4/13/2011 8:43 PM To: asi...@li.... Subject: [asio-users] Monitoring thread liveness using multiple threads witha single asio io_service We have a server implemented with boost::asio that uses a vector of threads with a single io_service as in the asio http server 3 sample program. We want to check on the liveness of threads by having each thread periodically call back to a thread manager so that we can confirm it is still running. To do that we have an inner loop that uses run_one() so we can call our heartbeat function after each action is completed (pseudo code): do { num_ops = io_svc.run_one(ec) heartbeat_to_thread_manager(); } while (num_ops > 0); However, asio makes no guarantees on how work is dispatched to threads. In our testing work seems to go preferentially to one thread for several iterations before going to another thread with no pattern that we can find. Is there some way we can change this solution so that we can be reasonably sure each thread will be called at least once in a some period of time or some other mechanism for monitoring thread liveness? Thanks, Mike ------------------------------------------------------------------------------ Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev _______________________________________________ asio-users mailing list asi...@li... https://lists.sourceforge.net/lists/listinfo/asio-users _______________________________________________ Using Asio? List your project at http://think-async.com/Asio/WhoIsUsingAsio |