From 6be5a6abd94d9d33562f8911578d246af0c7ab4d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 10 Jan 2011 21:37:09 +0000 Subject: Remove Raul::Command (mostly useless thin wrapper around a semaphore). Remove Semaphore::has_waiter (not portable). git-svn-id: http://svn.drobilla.net/lad/trunk/raul@2822 a436a847-0d15-0410-975c-d299462d15a1 --- raul/Command.hpp | 55 ------------------------------------------------------ raul/Semaphore.hpp | 13 ++++--------- 2 files changed, 4 insertions(+), 64 deletions(-) delete mode 100644 raul/Command.hpp diff --git a/raul/Command.hpp b/raul/Command.hpp deleted file mode 100644 index 886acc8..0000000 --- a/raul/Command.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* This file is part of Raul. - * Copyright (C) 2007-2009 David Robillard - * - * Raul is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Raul is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef RAUL_COMMAND_HPP -#define RAUL_COMMAND_HPP - -#include -#include "raul/Semaphore.hpp" - -namespace Raul { - - -/** A blocking command to be executed in the audio thread. - * - * This is useful for calling simple parameterless commands from another thread - * (OSC, GUI, etc) and waiting on the result. Works well for coarsely timed - * events (e.g. 'play' clicked in a GUI). - * - * Realtime safe on the command executing side. - * - * \ingroup raul - */ -class Command : boost::noncopyable { -public: - inline Command() : _sem(0) {} - - /** Caller context */ - inline void operator()() { _sem.wait(); } - - /** Execution context */ - inline bool pending() { return _sem.has_waiter(); } - inline void finish() { _sem.post(); } - -private: - Semaphore _sem; -}; - - -} // namespace Raul - -#endif // RAUL_COMMAND_HPP diff --git a/raul/Semaphore.hpp b/raul/Semaphore.hpp index c7b29ef..e17b788 100644 --- a/raul/Semaphore.hpp +++ b/raul/Semaphore.hpp @@ -52,6 +52,10 @@ public: #endif } + /** Destroy and reset the semaphore to an initial value. + * + * This must not be called while there are any waiters. + */ inline void reset(unsigned int initial) { #ifdef __APPLE__ MPDeleteSemaphore(_sem); @@ -62,15 +66,6 @@ public: #endif } - inline bool has_waiter() { - int val; - #ifdef __APPLE__ - #else - sem_getvalue(&_sem, &val); - #endif - return (val <= 0); - } - /** Increment (and signal any waiters). * * Realtime safe. -- cgit v1.2.1