Add default EntryPoints

This commit is contained in:
Vinnie Falco
2013-06-27 15:39:59 -07:00
parent b658f82510
commit 98ac0697a9
2 changed files with 22 additions and 2 deletions

View File

@@ -32,6 +32,13 @@ ThreadWithCallQueue::~ThreadWithCallQueue ()
stop (true); stop (true);
} }
ThreadWithCallQueue::EntryPoints* ThreadWithCallQueue::getDefaultEntryPoints () noexcept
{
static EntryPoints entryPoints;
return &entryPoints;
}
void ThreadWithCallQueue::start (EntryPoints* const entryPoints) void ThreadWithCallQueue::start (EntryPoints* const entryPoints)
{ {
{ {

View File

@@ -71,6 +71,12 @@ public:
*/ */
explicit ThreadWithCallQueue (String name); explicit ThreadWithCallQueue (String name);
/** Retrieve the default entry points.
The default entry points do nothing.
*/
static EntryPoints* getDefaultEntryPoints () noexcept;
/** Destroy a ThreadWithCallQueue. /** Destroy a ThreadWithCallQueue.
If the thread is still running it is stopped. The destructor blocks If the thread is still running it is stopped. The destructor blocks
@@ -78,9 +84,16 @@ public:
*/ */
~ThreadWithCallQueue (); ~ThreadWithCallQueue ();
/** Start the thread. /** Start the thread, with optional entry points.
If `entryPoints` is specified then the thread runs using those
entry points. If ommitted, the default entry simply do nothing.
This is useful for creating a thread whose sole activities are
performed through the call queue.
@param entryPoints An optional pointer to @ref EntryPoints.
*/ */
void start (EntryPoints* const entryPoints); void start (EntryPoints* const entryPoints = getDefaultEntryPoints ());
/* Stop the thread. /* Stop the thread.