-
Notifications
You must be signed in to change notification settings - Fork 16
CoreThread
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.
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.
Provides a synchronized dispatch queue for lambdas. CoreThread implements a run() member function that will run down the queue in its own thread.
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