]> Dogcows Code - chaz/yoink/commitdiff
prep for runloop code
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sat, 7 Aug 2010 00:46:49 +0000 (18:46 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sat, 7 Aug 2010 00:46:49 +0000 (18:46 -0600)
configure
src/Main.cc
src/moof/math.hh
src/moof/socket.hh
src/moof/thread.hh
src/moof/timer.hh

index 292639cb2a2cd8ed2bff026675125860a672e6cc..8cc0b0d183071963c2c32602c3d19421f49f83fd 100755 (executable)
--- a/configure
+++ b/configure
@@ -466,18 +466,18 @@ else
        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
 
 
 --
index ff2ce61d081fc47ffa5a8c42c35322ea99db614d..c76a6148bf84abb6a8b48c03f92f1e6de4055185 100644 (file)
@@ -48,7 +48,7 @@ Main::Main(moof::settings& settings, moof::video& video) :
                                                                                        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);
@@ -159,7 +159,7 @@ std::string Main::config_paths()
 
 void Main::setup_opengl()
 {
-       glEnable(GL_TEXTURE_2D);
+       //glEnable(GL_TEXTURE_2D);
        glEnable(GL_DEPTH_TEST);
        //glEnable(GL_CULL_FACE);
 
@@ -259,7 +259,7 @@ void Main::print_info(int argc, char* argv[])
                          << "       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);
@@ -269,12 +269,12 @@ void Main::print_info(int argc, char* argv[])
 #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);
@@ -284,12 +284,12 @@ void Main::print_info(int argc, char* argv[])
 #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);
index a960b0d1df1050370140d7869879d8ae25f7911c..14e8c78626acdb41bfedac1b8609e19d9588818b 100644 (file)
@@ -25,7 +25,7 @@
 #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)
index c592fdbfb097dd4488d2590a94c8ce267b9aadcf..08a5f50b1e88bec974ab9d1988d83eb10459a561 100644 (file)
@@ -1002,7 +1002,7 @@ public:
 
        void socket(moof::socket sock)
        {
-               mutex::scoped_lock lock(mutex_);
+               MOOF_MUTEX_LOCK(mutex_);
                socket_ = sock;
        }
 
@@ -1046,7 +1046,8 @@ private:
 
        moof::socket                    socket_;
        std::vector<function>   protocols_;
-       mutex                                   mutex_;
+
+       MOOF_DECLARE_MUTEX(mutex_);
 };
 
 
index 09caefd3048800a0cab77380bbceb62743700e96..72c6dc004147461706c1ae8d405b3c25fc924d62 100644 (file)
@@ -9,13 +9,15 @@
 *
 **************************************************************************/
 
+#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>
@@ -252,9 +254,12 @@ public:
                 * 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
@@ -305,34 +310,6 @@ public:
         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:
 
@@ -531,9 +508,12 @@ public:
                 * 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
@@ -580,34 +560,6 @@ public:
         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:
@@ -616,6 +568,15 @@ 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_
index f5c3583ccc0525c90adf616979fddfb82d8819ce..3ec4ef9d8e04bd23a1e6141d4c242e430f6d0d5e 100644 (file)
@@ -149,8 +149,13 @@ public:
         */
        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
This page took 0.03517 seconds and 4 git commands to generate.