From 2f719c364449f3e338822e7cc740daac0870cbc9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 16 Aug 2012 00:59:35 +0000 Subject: Remove Raul::Slave class. Merge Thread::stop() and Thread::join(). Clean thread shut down without the use of pthread_cancel(). git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4708 a436a847-0d15-0410-975c-d299462d15a1 --- raul/Thread.hpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'raul/Thread.hpp') diff --git a/raul/Thread.hpp b/raul/Thread.hpp index 6ac5aeb..f6f57d3 100644 --- a/raul/Thread.hpp +++ b/raul/Thread.hpp @@ -37,13 +37,18 @@ class Thread : Noncopyable public: virtual ~Thread(); - /** Start the thread if it is not already running. */ + /** Start the thread if it is not already running. + * + * This is separate from construction to prevent race conditions during + * construction of derived classes. + */ virtual void start(); - /** Stop the thread if it is running. */ - virtual void stop(); - - /** Wait until the thread exits. */ + /** Stop the thread and block the caller until the thread exits. + * + * This sets _exit_flag to true, derived classes must ensure they actually + * exit when this occurs. + */ virtual void join(); /** Set the scheduling policy for this thread. @@ -55,6 +60,11 @@ public: const std::string& name() const { return _name; } protected: + /** Construct a thread. + * + * Note this does not actually start a thread to prevent race conditions + * during construction. To actually begin execution, call start(). + */ explicit Thread(const std::string& name=""); /** Thread function to execute. -- cgit v1.2.1