-
Notifications
You must be signed in to change notification settings - Fork 15
CoreContext
Peter Ehrlich edited this page Jul 25, 2014
·
3 revisions
A context is a runtime generalization of the singleton pattern. Unlike a singleton, objects in a context are allowed to have a lifetime distinct from the lifetime of the enclosing application. Contexts also support a threading model via the CoreRunnable
type, which is implemented by CoreThread
and CoreJob
.
An anonymous context may be created with CoreContext::Create
or with AutoCreateContext
. A typical use pattern is as follows:
// Make a new child context
AutoCreateContext ctxt;
// Make this context current
CurrentContextPusher pshr(ctxt);
The above code creates a new context, and sets it current.