From 7b3b414258d2f3edae780c53114672560495e502 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 9 Aug 2007 05:38:36 +0000 Subject: Minor threading interface stuff for parallel Ingen. git-svn-id: http://svn.drobilla.net/lad/raul@690 a436a847-0d15-0410-975c-d299462d15a1 --- raul/Semaphore.hpp | 7 +++++-- raul/Thread.hpp | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/raul/Semaphore.hpp b/raul/Semaphore.hpp index 93dae0a..3bd6ac4 100644 --- a/raul/Semaphore.hpp +++ b/raul/Semaphore.hpp @@ -31,7 +31,8 @@ namespace Raul { * work in GDB. Turns out sem_wait can fail when run in GDB, and Debian * really needs to update it's man pages. * - * This class remains as a trivial (yet pretty) wrapper/abstraction. + * This class remains as a trivial (yet pretty) wrapper/abstraction, because + * Glib (idiotically) doesn't have a Semaphore class. * * \ingroup raul */ @@ -60,10 +61,12 @@ public: inline void wait() { while (sem_wait(&_sem) != 0) ; } /** Non-blocking version of wait(). + * + * \return true if decrement was successful (lock was acquired). * * Realtime safe? */ - inline int try_wait() { return sem_trywait(&_sem); } + inline bool try_wait() { return (sem_trywait(&_sem) == 0); } private: sem_t _sem; diff --git a/raul/Thread.hpp b/raul/Thread.hpp index e444c6e..29cade1 100644 --- a/raul/Thread.hpp +++ b/raul/Thread.hpp @@ -56,11 +56,11 @@ public: void set_scheduling(int policy, unsigned int priority); - const std::string& name() { return _name; } + const std::string& name() const { return _name; } void set_name(const std::string& name) { _name = name; } - const unsigned context() { return _context; } - void set_context(unsigned context) { _context = context; } + unsigned context() const { return _context; } + void set_context(unsigned context) { _context = context; } protected: Thread(const std::string& name=""); -- cgit v1.2.1