Add SharedFunction to replace boost::function

This commit is contained in:
Vinnie Falco
2013-09-06 13:11:05 -07:00
parent 88af355028
commit c35843fda5
9 changed files with 140 additions and 34 deletions

View File

@@ -45,7 +45,11 @@ class SharedHandler : public SharedObject
{
protected:
typedef boost::system::error_code error_code;
#if 0
typedef boost::function <void(void)> invoked_type;
#else
typedef SharedFunction <void(void), SharedHandlerAllocator <char> > invoked_type;
#endif
SharedHandler () noexcept { }
@@ -59,19 +63,19 @@ public:
virtual void operator() (error_code const&);
virtual void operator() (error_code const&, std::size_t);
/** Dispatch the Function on our context. */
/*
template <typename Dispatcher, typename Function>
void dispatch (Dispatcher& dispatcher, BOOST_ASIO_MOVE_ARG(Function) function)
{
dispatcher.dispatch (boost::bind (
&SharedHandler::invoke <Function>, this,
BOOST_ASIO_MOVE_CAST(Function)(function)));
}
*/
template <typename Function>
void invoke (BOOST_ASIO_MOVE_ARG(Function) f);
void invoke (BOOST_ASIO_MOVE_ARG(Function) f)
#if 0
;
#else
{
// The allocator will hold a reference to the SharedHandler
// so that we can safely destroy the function object.
invoked_type invoked (f,
SharedHandlerAllocator <char> (this));
invoke (invoked);
}
#endif
virtual void invoke (invoked_type& invoked) = 0;
virtual void* allocate (std::size_t size) = 0;