该类用于linux下的io_context::service,即scheduler中,用于表示所有操作的基类,并且,操作采用单链表,具体实现如下:
(1) complete(void* owner, const boost::system::error_code& ec, std::size_t bytes_transferred), 实际就是一个操作完成时调用的函数,实际就是调用构造函数中传入的函数指针func
(2) destory()表示将操作函数销毁
class scheduler;
// Base class for all operations. A function pointer is used instead of virtual
// functions to avoid the associated overhead.
class scheduler_operation BOOST_ASIO_INHERIT_TRACKED_HANDLER
{
public:
typedef scheduler_operation operation_type;
void complete(void* owner, const boost::system::error_code& ec,
std::size_t bytes_transferred)
{
func_(owner, this, ec, bytes_transferred);
}
void destroy()
{
func_(0, this, boost::system::error_code(), 0);
}
protected:
typedef void (*func_type)(void*,
scheduler_operation*,
const boost::system::error_code&, std::size_t);
scheduler_operation(func_type func)
: