Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1337


Ignore:
Timestamp:
May 20, 2008, 7:08:57 PM (16 years ago)
Author:
landauf
Message:

TclThreadManager should now work with old and new versions of boost.
tested with 1_33_1, 1_34_1, 1_35_0

Location:
code/branches/console
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/cmake/FindBoost.cmake

    r1230 r1337  
    116116  SET(Boost_INCLUDE_DIR
    117117#    ../libs/boost_1_33_1
    118     ../libs/boost_1_35_0
     118    ../libs/boost_1_34_1
     119#    ../libs/boost_1_35_0
    119120  )
    120121ELSE(WIN32)
     
    192193  gcc-1_33_1
    193194  gcc-mt-1_33_1
     195  mgw34-mt-1_34_1
    194196  mgw34-mt-1_35
    195197)
  • code/branches/console/src/core/TclThreadManager.cc

    r1276 r1337  
    6767        this->orxonoxInterpreterBundle_.id_ = 0;
    6868        this->orxonoxInterpreterBundle_.interpreter_ = TclBind::getInstance().getTclInterpreter();
     69#if (BOOST_VERSION >= 103500)
    6970        this->threadID_ = boost::this_thread::get_id();
     71#else
     72        //
     73#endif
    7074    }
    7175
     
    119123                    {
    120124                        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
    121                         boost::mutex::scoped_lock interpreter_lock(bundle->interpreterMutex_, boost::defer_lock_t());
     125#if (BOOST_VERSION >= 103500)
     126                        boost::mutex::scoped_try_lock interpreter_lock(bundle->interpreterMutex_);
     127#else
     128                        boost::try_mutex::scoped_try_lock interpreter_lock(bundle->interpreterMutex_);
     129#endif
    122130                        try
    123131                        {
     
    125133                            {
    126134                                TclThreadManager::getInstance().orxonoxEvalCondition_.notify_one();
     135#if (BOOST_VERSION >= 103500)
    127136                                boost::this_thread::yield();
     137#else
     138                                boost::thread::yield();
     139#endif
    128140                            }
    129141                        } catch (...) {}
     
    136148
    137149                TclThreadManager::getInstance().orxonoxEvalCondition_.notify_one();
     150#if (BOOST_VERSION >= 103500)
    138151                boost::this_thread::yield();
     152#else
     153                boost::thread::yield();
     154#endif
    139155            }
    140156
     
    183199            output += "\t\t";
    184200            {
    185                 boost::mutex::scoped_lock interpreter_lock((*it).second->interpreterMutex_, boost::defer_lock_t());
     201#if (BOOST_VERSION >= 103500)
     202                boost::mutex::scoped_try_lock interpreter_lock((*it).second->interpreterMutex_);
     203#else
     204                boost::try_mutex::scoped_try_lock interpreter_lock((*it).second->interpreterMutex_);
     205#endif
    186206                if (interpreter_lock.try_lock())
    187207                    output += "ready";
     
    332352    void TclThreadManager::error(const std::string& error)
    333353    {
     354#if (BOOST_VERSION >= 103500)
    334355        if (boost::this_thread::get_id() != this->threadID_)
     356#else
     357        if (boost::thread() != this->threadID_)
     358#endif
    335359        {
    336360            boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
    337361            if (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
    338362            {
     363#if (BOOST_VERSION >= 103500)
    339364                boost::this_thread::yield();
     365#else
     366                boost::thread::yield();
     367#endif
    340368                return;
    341369            }
     
    347375    void TclThreadManager::debug(const std::string& error)
    348376    {
     377#if (BOOST_VERSION >= 103500)
    349378        if (boost::this_thread::get_id() != this->threadID_)
     379#else
     380        if (boost::thread() != this->threadID_)
     381#endif
    350382        {
    351383            boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
    352384            if (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
    353385            {
     386#if (BOOST_VERSION >= 103500)
    354387                boost::this_thread::yield();
     388#else
     389                boost::thread::yield();
     390#endif
    355391                return;
    356392            }
     
    461497            if (this->updateQueriersList(querier, &this->orxonoxInterpreterBundle_))
    462498            {
     499#if (BOOST_VERSION >= 103500)
    463500                boost::mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
     501#else
     502                boost::try_mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
     503#endif
    464504                this->orxonoxEvalCondition_.wait(interpreter_lock);
    465505
     
    498538                if (this->updateQueriersList(querier, target))
    499539                {
    500                     boost::mutex::scoped_lock interpreter_lock(target->interpreterMutex_, boost::defer_lock_t());
     540#if (BOOST_VERSION >= 103500)
     541                    boost::mutex::scoped_try_lock interpreter_lock(target->interpreterMutex_);
     542#else
     543                    boost::try_mutex::scoped_try_lock interpreter_lock(target->interpreterMutex_);
     544#endif
    501545                    bool successfullyLocked = false;
    502546                    try
     
    507551                        {
    508552                            while (!interpreter_lock.try_lock())
     553                            {
     554#if (BOOST_VERSION >= 103500)
    509555                                boost::this_thread::yield();
     556#else
     557                                boost::thread::yield();
     558#endif
     559                            }
    510560
    511561                            successfullyLocked = true;
     
    540590        {
    541591            this->orxonoxEvalCondition_.notify_one();
     592#if (BOOST_VERSION >= 103500)
    542593            boost::this_thread::yield();
     594#else
     595            boost::thread::yield();
     596#endif
    543597        }
    544598
     
    562616
    563617        {
     618#if (BOOST_VERSION >= 103500)
    564619            boost::mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
     620#else
     621            boost::try_mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
     622#endif
    565623            unsigned long maxtime = (unsigned long)(dt * 1000000 * TCLTHREADMANAGER_MAX_CPU_USAGE);
    566624            Ogre::Timer timer;
     
    577635    {
    578636        TclThreadManager::getInstance().debug("TclThread_execute: " + command);
     637#if (BOOST_VERSION >= 103500)
    579638        boost::mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_);
     639#else
     640        boost::try_mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_);
     641#endif
    580642        try
    581643        {
  • code/branches/console/src/core/TclThreadManager.h

    r1276 r1337  
    3636#include <boost/thread/mutex.hpp>
    3737#include <boost/thread/condition.hpp>
     38#include <boost/thread/thread.hpp>
    3839
    3940#include "CorePrereqs.h"
     
    119120            boost::condition fullQueueCondition_;
    120121            boost::condition orxonoxEvalCondition_;
     122#if (BOOST_VERSION >= 103500)
    121123            boost::thread::id threadID_;
     124#else
     125            boost::thread threadID_;
     126#endif
    122127    };
    123128
Note: See TracChangeset for help on using the changeset viewer.