mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add SharedFunction to replace boost::function
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user