Boost logo

Boost :

From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-12-14 18:30:58

Hi Simon,

--- simon meiklejohn <simon_at_[hidden]> wrote:
> Is it feasible to accomplish something like this with a class
> something like the following (but more correct hopefully)
<snip code>

Yes, I think it's feasible. It would probably be something more

class abstract_dispatcher
  virtual ~abstract_dispatcher();
  virtual void post(function<void(void)> f) = 0;
  virtual void dispatch(function<void(void)> f) = 0;

  // Note: non-virtual template member function. Can reuse
  // asio::detail::wrapper_handler to implement it.
  template <typename Handler>
  unspecified wrap(Handler h);

template <typename Dispatcher_Impl>
class dispatcher : public abstract_dispatcher
  // Forwarding constructors here ...

  void post(function<void(void)> f) {; }
  void dispatch(function<void(void)> f) { impl_.dispatch(f); }

  Dispatcher_Impl impl_;

And to use:

// An abstract dispatcher that owns its implementation
dispatcher<my_dispatcher> d(... args here ...);

// An abstract dispatcher that doesn't own the implementation.
demuxer d1;
dispatcher<demuxer&> d2(d1);


Boost list run by bdawes at, gregod at, cpdaniel at, john at