config.NDEBUG = true
end
-config.USE_CLOCK_GETTIME = get_feature("clock_gettime")
-config.USE_DOUBLE_PRECISION = get_feature("double-precision")
-config.USE_HOTLOADING = get_feature("hotload")
-config.USE_THREADS = get_feature("threads")
+config.ENABLE_CLOCK_GETTIME = get_feature("clock_gettime")
+config.ENABLE_DOUBLE_PRECISION = get_feature("double-precision")
+config.ENABLE_HOTLOADING = get_feature("hotload")
+config.ENABLE_THREADS = get_feature("threads")
if get_feature("profile") then
- config.PROFILING_ENABLED = true
+ config.ENABLE_PROFILING = true
add_cflag("-pg")
LDFLAGS = LDFLAGS .. "-pg"
end
-if get_package("gtk") then config.USE_GTK = true end
-if get_package("qt4") then config.USE_QT4 = true end
+if get_package("gtk") then config.WITH_GTK = true end
+if get_package("qt4") then config.WITH_QT4 = true end
--
boost::bind(&Main::setup_opengl));
setup_opengl();
-#if USE_HOTLOADING
+#if ENABLE_HOTLOADING
hotload_timer_.init(boost::bind(&moof::resource::reload_as_needed),
SCALAR(0.25),
moof::timer::repeat);
void Main::setup_opengl()
{
- glEnable(GL_TEXTURE_2D);
+ //glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
//glEnable(GL_CULL_FACE);
<< " Assets: " << assets << std::endl
<< "Build options: ";
-#if USE_CLOCK_GETTIME
+#if ENABLE_CLOCK_GETTIME
print_option("clock_gettime", true);
#else
print_option("clock_gettime", false);
#else
print_option("debug", false);
#endif
-#if USE_GTK
+#if WITH_GTK
print_option("gtk", true);
#else
print_option("gtk", false);
#endif
-#if USE_HOTLOADING
+#if ENABLE_HOTLOADING
print_option("hotload", true);
#else
print_option("hotload", false);
#else
print_option("profile", false);
#endif
-#if USE_QT4
+#if WITH_QT4
print_option("qt4", true);
#else
print_option("qt4", false);
#endif
-#if USE_THREADS
+#if ENABLE_THREADS
print_option("threads", true);
#else
print_option("threads", false);
#include <SDL/SDL_opengl.h>
-#if USE_DOUBLE_PRECISION
+#if ENABLE_DOUBLE_PRECISION
typedef GLdouble GLscalar;
#define GL_SCALAR GL_DOUBLE
#define SCALAR(D) (D)
void socket(moof::socket sock)
{
- mutex::scoped_lock lock(mutex_);
+ MOOF_MUTEX_LOCK(mutex_);
socket_ = sock;
}
moof::socket socket_;
std::vector<function> protocols_;
- mutex mutex_;
+
+ MOOF_DECLARE_MUTEX(mutex_);
};
*
**************************************************************************/
+#ifndef _MOOF_THREAD_HH_
+#define _MOOF_THREAD_HH_
+
/**
* \file thread.hh
* Light C++ wrapper around the SDL threads API.
*/
-#ifndef _MOOF_THREAD_HH_
-#define _MOOF_THREAD_HH_
+#include "config.h"
#include <boost/bind.hpp>
#include <boost/function.hpp>
* Construct a lock.
* \param mutex The mutex.
*/
- explicit lock(mutex& mutex) :
+ explicit lock(mutex& mutex, bool lock = true) :
mutex_(mutex),
- is_locked_(false) {}
+ is_locked_(false)
+ {
+ if (lock) if (!acquire()) throw "mutex lock not acquired";
+ }
/**
* Deconstruct a lock. The lock is automagically released if it is
friend class condition;
};
- /**
- * This type of lock tries to acquire a lock on the mutex during
- * construction and releases the lock on deconstruction.
- */
- class scoped_lock : private lock
- {
- public:
-
- /**
- * Construct a lock.
- * \param mutex The mutex.
- */
- explicit scoped_lock(mutex& mutex) :
- lock(mutex)
- {
- acquire();
- }
-
- /**
- * Get whether or not the mutex is locked.
- * \return True if the mutex is locked, false otherwise.
- */
- bool is_locked() const
- {
- return lock::is_locked();
- }
- };
-
private:
* Construct a lock.
* \param semaphore The semaphore.
*/
- explicit lock(semaphore& semaphore) :
+ explicit lock(semaphore& semaphore, bool lock = true) :
semaphore_(semaphore),
- is_locked_(false) {}
+ is_locked_(false)
+ {
+ if (lock) if (!acquire()) throw "semaphore lock not acquired";
+ }
/**
* Deconstruct a lock. The lock is automagically released if it is
semaphore& semaphore_;
bool is_locked_;
};
-
- /**
- * This type of lock tries to acquire a lock on the semaphore during
- * construction and releases the lock on deconstruction.
- */
- class scoped_lock : private lock
- {
- public:
-
- /**
- * Construct a lock.
- * \param semaphore The semaphore.
- */
- explicit scoped_lock(semaphore& semaphore) :
- lock(semaphore)
- {
- acquire();
- }
-
- /**
- * Get whether or not the semaphore is locked.
- * \return True if the semaphore is locked, false otherwise.
- */
- bool is_locked() const
- {
- return lock::is_locked();
- }
- };
private:
};
+#if ENABLE_THREADS
+#define MOOF_DECLARE_MUTEX(M) moof::mutex M
+#define MOOF_MUTEX_LOCK(M) moof::mutex::lock lock_##M(M)
+#else
+#define MOOF_DECLARE_MUTEX(M)
+#define MOOF_MUTEX_LOCK(M)
+#endif
+
+
} // namespace moof
#endif // _MOOF_THREAD_HH_
*/
scalar seconds_remaining() const;
+ /**
+ * Get the absolute time of the next expiration of this timer.
+ * \return Seconds.
+ */
scalar next_expiration() const;
+
/**
* Get whether or not the timer is expired. A timer on a repeating
* schedule will never be expired since it will always have a scheduled