[Assorted-commits] SF.net SVN: assorted: [746] cpp-commons/trunk/src/commons/boost/delegates.h
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-05-08 19:31:14
|
Revision: 746 http://assorted.svn.sourceforge.net/assorted/?rev=746&view=rev Author: yangzhang Date: 2008-05-08 12:31:11 -0700 (Thu, 08 May 2008) Log Message: ----------- forgot to add this earlier (for boost/threads stuff) Added Paths: ----------- cpp-commons/trunk/src/commons/boost/delegates.h Added: cpp-commons/trunk/src/commons/boost/delegates.h =================================================================== --- cpp-commons/trunk/src/commons/boost/delegates.h (rev 0) +++ cpp-commons/trunk/src/commons/boost/delegates.h 2008-05-08 19:31:11 UTC (rev 746) @@ -0,0 +1,35 @@ +#ifndef COMMONS_DELEGATES_H +#define COMMONS_DELEGATES_H + +#include <boost/function.hpp> +#include <boost/scoped_ptr.hpp> + +namespace commons +{ + + using namespace boost; + + /** + * Delegate for running a 0-ary void function. + */ + void + run_function0(void *p) + { + scoped_ptr< const function0<void> > pf((const function0<void>*) p); + try { (*pf)(); } + catch (exception ex) { cerr << ex.what() << endl; } + } + + /** + * NULL void*-returning delegate for running a 0-ary void function. + */ + void* + run_function0_null(void* p) + { + run_function0(p); + return NULL; + } + +} + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |