Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 51 lines (41 sloc) 1.136 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#ifndef RBX_AUXILIARY_THREADS_H
#define RBX_AUXILIARY_THREADS_H

#include "util/thread.hpp"

#include <list>

namespace rubinius {
  class AuxiliaryThread {
  public:

    virtual ~AuxiliaryThread() { };
    virtual void shutdown(STATE) { };
    virtual void before_exec(STATE) { };
    virtual void after_exec(STATE) { };
    virtual void before_fork(STATE) { };
    virtual void after_fork_parent(STATE) { };
    virtual void after_fork_child(STATE) { };
  };

  class AuxiliaryThreads {
  private:
    bool fork_in_progress_;
    bool exec_in_progress_;
    bool shutdown_in_progress_;
    utilities::thread::Mutex mutex_;
    std::list<AuxiliaryThread*> threads_;

  public:
    AuxiliaryThreads()
      : fork_in_progress_(false)
      , exec_in_progress_(false)
      , shutdown_in_progress_(false)
    {
    }

    void register_thread(AuxiliaryThread* thread);
    void unregister_thread(AuxiliaryThread* thread);

    void init();
    void shutdown(STATE);
    void before_exec(STATE);
    void after_exec(STATE);
    void before_fork(STATE);
    void after_fork_parent(STATE);
    void after_fork_child(STATE);
  };
}

#endif
Something went wrong with that request. Please try again.