• Marian Triebe's avatar
    Add possibility to register thread hooks · d8dc4018
    Marian Triebe authored
    Example:
    ```
    class my_thread_hooks : public thread_hook {
    public:
      my_thread_hooks(/*arguments...*/) {
        // ...
      }
      /// Called by the actor system once before starting any threads.
      virtual void init(actor_system&) {
        // ...
      }
    
      /// Called whenever the actor system has started a new thread.
      /// To access a reference to the started thread use `std::this_thread`.
      /// @warning must the thread-safe
      virtual void thread_started() {
        // ...
      }
    
      /// Called whenever a thread is about to quit.
      /// To access a reference to the terminating thread use `std::this_thread`.
      /// @warning must the thread-safe
      virtual void thread_terminates() {
        // ...
      }
    };
    // ...
    actor_system_config cfg{};
    cfg.add_add_thread_hook<my_thread_hooks>(/*arguments for constructor*/);
    // ...
    ```
    
    closes #603
    d8dc4018
all.hpp 13.2 KB