ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
Re: [boost] thread yield
by Peter Petrov other posts by this author
Sep 23 2005 6:00PM messages near this date
Re: [boost] [tools][bcp] using boost internally in other libraries | Re: [boost] [preprocessor][dmc] improved dmc conformance
SOURCE Jason Hise wrote:

>  Alright, I will add some more context to the discussion.  This is being 
>  used for a 'timeout lifetime' for the singleton library.  The idea is 
>  that a singleton which is cheap to create but expensive to hold on to 
>  could automatically be destroyed if it goes unused a certain amount of 
>  time, and be recreated the next time it is needed.  To implement this 
>  idea I create a timeout thread when the instance is created, and force 
>  that thread to sleep until the timeout time is reached.  If at that 
>  point the timeout time has been extended, the thread sleeps again, 
>  otherwise it destroys the instance and exits.
>  
>  The problem is that if the process is exiting I would like to force the 
>  thread to wake up and time out early to ensure that the singleton get 
>  destroyed.

Instead of sleeping, use timed_wait on a condition variable. Upon 
awakening, check the cause (which could be timeout, valid signal, or 
spurious wakeup).

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved