Boost C++ 库

……是世界上备受推崇、设计精良的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, C++ Coding Standards

服务要求 - Boost C++ 函数库
PrevUpHomeNext

如果一个类公开且明确地派生自 execution_context::service,或者公开且明确地派生自另一个服务,则该类是一个 服务。对于一个服务 SS::key_type 必须是有效的,并且表示一个类型(C++Std [temp.deduct]),is_base_of_v<typename S::key_type, S> 必须为 true,并且 S 必须满足 Destructible 要求(C++Std [destructible])。

所有服务构造函数的第一个参数都必须是对 execution_context 的左值引用。此参数表示一个代表一组服务的 execution_context 对象,服务对象将成为该组的成员。[注意:这些构造函数可能由 make_service 函数调用。 —结束注意]

服务必须提供一个显式构造函数,该构造函数具有一个类型为 execution_context 的左值引用的单个参数。[注意:此构造函数可能由 use_service 函数调用。 —结束注意]

class my_service : public execution_context::service
{
public:
  typedef my_service key_type;
  explicit my_service(execution_context& ctx);
  my_service(execution_context& ctx, int some_value);
private:
  virtual void shutdown() noexcept override;
  ...
};

服务的 shutdown 成员函数必须销毁服务持有的所有用户定义函数对象的副本。


PrevUpHomeNext