asio C++ library

PrevUpHomeNext

Cancellation handler requirements

A value h of a cancellation handler class should work correctly in the expression h(t), where t is a value of type asio::cancellation_type.

Examples

A free function as a cancellation handler:

void cancellation_handler(
    asio::cancellation_type type)
{
  ...
}

slot.assign(cancellation_handler);

A cancellation handler function object:

struct cancellation_handler
{
  ...
  void operator()(
      asio::cancellation_type type)
  {
    ...
  }
  ...
};

cancellation_handler& h = slot.assign(cancellation_handler{ ... });

A lambda as a cancellation handler:

auto& h = slot.assign(
    [](asio::cancellation_type type)
    {
      ...
    });

PrevUpHomeNext