diff --git a/modules/beast_basics/threads/beast_ThreadWithCallQueue.cpp b/modules/beast_basics/threads/beast_ThreadWithCallQueue.cpp index b0141aaeac..c946e8e82b 100644 --- a/modules/beast_basics/threads/beast_ThreadWithCallQueue.cpp +++ b/modules/beast_basics/threads/beast_ThreadWithCallQueue.cpp @@ -32,6 +32,13 @@ ThreadWithCallQueue::~ThreadWithCallQueue () stop (true); } +ThreadWithCallQueue::EntryPoints* ThreadWithCallQueue::getDefaultEntryPoints () noexcept +{ + static EntryPoints entryPoints; + + return &entryPoints; +} + void ThreadWithCallQueue::start (EntryPoints* const entryPoints) { { diff --git a/modules/beast_basics/threads/beast_ThreadWithCallQueue.h b/modules/beast_basics/threads/beast_ThreadWithCallQueue.h index 6f94b42a97..8a52263e31 100644 --- a/modules/beast_basics/threads/beast_ThreadWithCallQueue.h +++ b/modules/beast_basics/threads/beast_ThreadWithCallQueue.h @@ -71,6 +71,12 @@ public: */ explicit ThreadWithCallQueue (String name); + /** Retrieve the default entry points. + + The default entry points do nothing. + */ + static EntryPoints* getDefaultEntryPoints () noexcept; + /** Destroy a ThreadWithCallQueue. If the thread is still running it is stopped. The destructor blocks @@ -78,9 +84,16 @@ public: */ ~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.