diff options
author | David Robillard <d@drobilla.net> | 2006-10-16 07:28:30 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-10-16 07:28:30 +0000 |
commit | 4e68bf298f9fe4445925b4fe39f28e364a216fd2 (patch) | |
tree | 199cf1eb30a32554cffd5f5aa1ac26ad7bf89dba | |
parent | e22d5e4bfa4e5de0cba97c0e1a4ea71de9ecbe48 (diff) | |
download | raul-4e68bf298f9fe4445925b4fe39f28e364a216fd2.tar.gz raul-4e68bf298f9fe4445925b4fe39f28e364a216fd2.tar.bz2 raul-4e68bf298f9fe4445925b4fe39f28e364a216fd2.zip |
Used boost::noncopyable to eliminate undefined private copy constructors spread everywhere.
git-svn-id: http://svn.drobilla.net/lad/raul@182 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | raul/Condition.h | 5 | ||||
-rw-r--r-- | raul/Mutex.h | 5 | ||||
-rw-r--r-- | raul/Process.h | 9 | ||||
-rw-r--r-- | raul/Queue.h | 7 | ||||
-rw-r--r-- | raul/Semaphore.h | 3 | ||||
-rw-r--r-- | raul/Slave.h | 4 | ||||
-rw-r--r-- | raul/Thread.h | 7 |
8 files changed, 19 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac index c7c12a2..635c127 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,9 @@ if test "$build_smart_pointers" = "yes"; then AC_CHECK_HEADER([boost/weak_ptr.hpp], [], AC_MSG_ERROR([You need the boost headers package (e.g. libboost-dev)])) + + AC_CHECK_HEADER([boost/utility.hpp], [], + AC_MSG_ERROR([You need the boost headers package (e.g. libboost-dev)])) AC_SUBST(BOOST_CFLAGS) AC_SUBST(BOOST_LIBS) diff --git a/raul/Condition.h b/raul/Condition.h index 0f20c29..5517225 100644 --- a/raul/Condition.h +++ b/raul/Condition.h @@ -18,15 +18,16 @@ #define RAUL_CONDITION_H #include <pthread.h> +#include <boost/utility.hpp> -/** Trivial (but pretty) wrapper around POSIX Conditions (zero overhead). +/** Trivial (zero overhead) wrapper around POSIX Conditions. * * A semaphore that isn't a counter, is slow, and not realtime safe. Yay. * * \ingroup raul */ -class Condition { +class Condition : boost::noncopyable { public: inline Condition() { pthread_cond_init(&_cond, NULL); } diff --git a/raul/Mutex.h b/raul/Mutex.h index 57dedba..bf16d3c 100644 --- a/raul/Mutex.h +++ b/raul/Mutex.h @@ -18,13 +18,14 @@ #define RAUL_MUTEX_H #include <pthread.h> +#include <boost/utility.hpp> -/** Trivial (but pretty) wrapper around POSIX Mutexes (zero overhead). +/** Trivial (zero overhead) wrapper around POSIX Mutexes. * * \ingroup raul */ -class Mutex { +class Mutex : boost::noncopyable { public: inline Mutex() { pthread_mutex_init(&_mutex, NULL); } diff --git a/raul/Process.h b/raul/Process.h index 698e1b9..68efb10 100644 --- a/raul/Process.h +++ b/raul/Process.h @@ -20,12 +20,14 @@ #include <string> #include <iostream> #include <unistd.h> +#include <boost/utility.hpp> + /** A child process. * * \ingroup raul */ -class Process +class Process : boost::noncopyable { public: @@ -75,10 +77,7 @@ public: } private: - // .... no :) (undefined) - Process(); - Process(const Process&); - Process& operator=(const Process&); + Process() {} }; diff --git a/raul/Queue.h b/raul/Queue.h index 071ed4e..36d1cca 100644 --- a/raul/Queue.h +++ b/raul/Queue.h @@ -19,6 +19,7 @@ #include <cassert> #include <cstdlib> +#include <boost/utility.hpp> /** Realtime-safe single-reader single-writer queue (aka lock-free ringbuffer) @@ -32,7 +33,7 @@ * \ingroup raul */ template <typename T> -class Queue +class Queue : boost::noncopyable { public: Queue(size_t size); @@ -50,10 +51,6 @@ public: inline T& pop(); private: - // Prevent copies (these are undefined) - Queue(const Queue& copy); - Queue& operator=(const Queue& copy); - volatile size_t m_front; ///< Index to front of queue (circular) volatile size_t m_back; ///< Index to back of queue (one past last element) (circular) const size_t m_size; ///< Size of @ref m_objects (you can store m_size-1 objects) diff --git a/raul/Semaphore.h b/raul/Semaphore.h index 213e1d0..bd06b65 100644 --- a/raul/Semaphore.h +++ b/raul/Semaphore.h @@ -18,6 +18,7 @@ #define RAUL_SEMAPHORE_H #include <semaphore.h> +#include <boost/utility.hpp> /** Trivial wrapper around POSIX semaphores (zero memory overhead). @@ -31,7 +32,7 @@ * * \ingroup raul */ -class Semaphore { +class Semaphore : boost::noncopyable { public: inline Semaphore(unsigned int initial) { sem_init(&m_sem, 0, initial); } diff --git a/raul/Slave.h b/raul/Slave.h index fb0c67c..8f20140 100644 --- a/raul/Slave.h +++ b/raul/Slave.h @@ -49,10 +49,6 @@ protected: Semaphore _whip; private: - // Prevent copies (undefined) - Slave(const Slave&); - Slave& operator=(const Slave&); - inline void _run() { while (true) { diff --git a/raul/Thread.h b/raul/Thread.h index 04a7be4..b7fd9c4 100644 --- a/raul/Thread.h +++ b/raul/Thread.h @@ -20,6 +20,7 @@ #include <string> #include <iostream> #include <pthread.h> +#include <boost/utility.hpp> /** Abstract base class for a thread. @@ -29,7 +30,7 @@ * * \ingroup raul */ -class Thread +class Thread : boost::noncopyable { public: Thread() : _pthread_exists(false) {} @@ -88,10 +89,6 @@ protected: virtual void _run() = 0; private: - // Prevent copies (undefined) - Thread(const Thread&); - Thread& operator=(const Thread&); - inline static void* _static_run(void* me) { Thread* myself = (Thread*)me; myself->_run(); |