Skip to content
Graham Tremper edited this page Jul 28, 2014 · 2 revisions

CoreThread is the most featured thread class in Autowiring, inheriting from both BasicThread and DispatchQueue. Lambdas can be added to an internal queue with the overloaded operator+=. Synchronization is provided internally, and all appended lambdas will be run sequentially.

BasicThread

Provides a pure virtual run() member function that is run in its own thread. Inherit from this class if you just want to have an object run run() in a thread.

DispatchQueue

Provides a synchronized dispatch queue for lambdas. CoreThread implements a run() member function that will run down the queue in its own thread.

Usage

AutoRequred<CoreThread> thread;

*thread += []{
  std::cout << "First lambda" << std::endl;
}

// Lambda not run until context is "Initiated"

AutoCurrentContext ctxt;
ctxt->Initiate();
// "First lambda" printed

*thread += [] {
  std::cout << "Second lambda" << std::endl;
}
// "Second lambda" printed