Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1247


Ignore:
Timestamp:
May 8, 2008, 1:46:05 AM (16 years ago)
Author:
landauf
Message:

several changes in TclThreadManager but couldn't yet fix the bug

Location:
code/branches/console/src/core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/Executor.h

    r1062 r1247  
    3535#include "util/SubString.h"
    3636#include "util/String.h"
     37#include "util/Math.h"
    3738#include "Functor.h"
    3839#include "Debug.h"
     
    100101            COUT(5) << tokens[i]; \
    101102        } \
    102         COUT(5) << ") and " << (paramCount - tokens.size()) << " default values ("; \
     103        COUT(5) << ") and " << max((int)paramCount - (int)tokens.size(), 0) << " default values ("; \
    103104        for (unsigned int i = tokens.size(); i < paramCount; i++) \
    104105        { \
  • code/branches/console/src/core/TclBind.cc

    r1230 r1247  
    137137        catch (std::exception const &e)
    138138        {
    139             COUT(1) << "Error while executing tcl: " << e.what() << std::endl;
     139            COUT(1) << "Error while executing Tcl: " << e.what() << std::endl;
    140140        }
    141141
     
    156156        catch (std::exception const &e)
    157157        {
    158             COUT(1) << "Error while executing tcl: " << e.what() << std::endl;
     158            COUT(1) << "Error while executing Tcl: " << e.what() << std::endl;
    159159        }
    160160
  • code/branches/console/src/core/TclThreadManager.cc

    r1230 r1247  
    5353    ConsoleCommand(TclThreadManager, execute,   AccessLevel::None, false);
    5454    ConsoleCommand(TclThreadManager, query,     AccessLevel::None, false);
     55    ConsoleCommand(TclThreadManager, status,    AccessLevel::None, false);
     56    ConsoleCommand(TclThreadManager, dump,      AccessLevel::None, false);
    5557
    5658    TclThreadManager* instance = &TclThreadManager::getInstance();
     
    6264        this->IDcount_ = 0;
    6365        this->isReady_ = false;
     66        this->isQuerying_ = false;
     67        this->queryID_ = 0;
    6468    }
    6569
     
    103107    }
    104108
     109    void TclThreadManager::status()
     110    {
     111        COUT(0) << "Thread ID" << '\t' << "Queue size" << '\t' << "State" << std::endl;
     112
     113        std::string output = "Orxonox";
     114        output += "\t\t";
     115        {
     116            // mutex orxqueue
     117            boost::mutex::scoped_lock lock(TclThreadManager::getInstance().orxonoxQueueMutex_);
     118            output += getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().orxonoxQueue_.size());
     119        }
     120        output += "\t\t";
     121        {
     122            // mutex orxstate
     123            boost::mutex::scoped_lock lock(TclThreadManager::getInstance().orxonoxStateMutex_);
     124            if (TclThreadManager::getInstance().isReady_)
     125                output += "ready";
     126            else
     127                output += "busy";
     128        }
     129        COUT(0) << output << std::endl;
     130
     131        // mutex threads
     132        boost::mutex::scoped_lock lock(TclThreadManager::getInstance().threadsMutex_);
     133        for (std::map<unsigned int, TclThread*>::const_iterator it = TclThreadManager::getInstance().threads_.begin(); it != TclThreadManager::getInstance().threads_.end(); ++it)
     134        {
     135            std::string output = getConvertedValue<unsigned int, std::string>((*it).first);
     136            output += "\t\t";
     137            {
     138                boost::mutex::scoped_lock lock(TclThreadManager::getInstance().threadQueuesMutex_);
     139                std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::const_iterator it2 = TclThreadManager::getInstance().threadQueues_.find((*it).first);
     140                if (it2 != TclThreadManager::getInstance().threadQueues_.end())
     141                    output += getConvertedValue<unsigned int, std::string>((*it2).second.first.size());
     142                else
     143                    output += "-";
     144            }
     145            output += "\t\t";
     146            if (TclThreadManager::getInstance().getState((*it).second) == TclThread::Ready)
     147                output += "ready";
     148            else
     149                output += "busy";
     150
     151            COUT(0) << output << std::endl;
     152        }
     153    }
     154
     155    void TclThreadManager::dump(unsigned int threadID)
     156    {
     157        if (threadID == 0)
     158        {
     159            // mutex orxqueue
     160            boost::mutex::scoped_lock lock(TclThreadManager::getInstance().orxonoxQueueMutex_);
     161
     162            COUT(0) << "Queue dump of Orxonox:" << std::endl;
     163            for (unsigned int index = 0; index < TclThreadManager::getInstance().orxonoxQueue_.size(); index++)
     164            {
     165                std::string command = TclThreadManager::getInstance().orxonoxQueue_.front();
     166                COUT(0) << index << ": " << command << std::endl;
     167                TclThreadManager::getInstance().orxonoxQueue_.pop();
     168                TclThreadManager::getInstance().orxonoxQueue_.push(command);
     169            }
     170        }
     171        else
     172        {
     173            // mutex threadqueues
     174            boost::mutex::scoped_lock lock(TclThreadManager::getInstance().threadQueuesMutex_);
     175
     176            std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::iterator it = TclThreadManager::getInstance().threadQueues_.find(threadID);
     177            if (it != TclThreadManager::getInstance().threadQueues_.end())
     178            {
     179                COUT(0) << "Queue dump of Tcl-thread " << threadID << ":" << std::endl;
     180                for (unsigned int index = 0; index < (*it).second.first.size(); index++)
     181                {
     182                    std::string command = (*it).second.first.front();
     183                    COUT(0) << index << ": " << command << std::endl;
     184                    (*it).second.first.pop();
     185                    (*it).second.first.push(command);
     186                }
     187            }
     188            else
     189            {
     190                COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
     191            }
     192        }
     193    }
     194
    105195    void TclThreadManager::tcl_execute(Tcl::object const &args)
    106196    {
    107 std::cout << "3_1\n";
    108197std::cout << "Tcl-thread_execute: args: " << args.get() << std::endl;
    109198        std::string command = args.get();
     
    115204    }
    116205
    117     std::string TclThreadManager::tcl_orxonox(Tcl::object const &args)
    118     {
    119 std::cout << "4_1\n";
    120 std::cout << "Tcl-thread_orxonox: args: " << args.get() << std::endl;
     206    std::string TclThreadManager::tcl_query(int id, Tcl::object const &args)
     207    {
     208std::cout << "Tcl-thread_query: id: " << id << " args: " << args.get()  << std::endl;
     209        {
     210            // mutex query
     211            boost::mutex::scoped_lock lock(TclThreadManager::getInstance().orxonoxQueryMutex_);
     212            if (TclThreadManager::getInstance().isQuerying_ && (id == (int)TclThreadManager::getInstance().queryID_))
     213            {
     214                COUT(1) << "Error: Orxonox Tcl-interpreter can't be queried right now." << std::endl;
     215                return "";
     216            }
     217        }
     218
    121219        std::string command = args.get();
    122220
    123         if (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
     221        while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
    124222            command = command.substr(1, command.size() - 2);
    125223
     
    129227    Tcl::interpreter* TclThreadManager::createTclInterpreter(unsigned int threadID) const
    130228    {
    131         Tcl::interpreter* i = new Tcl::interpreter(TclBind::getInstance().getTclLibPath());
    132 
    133         i->def("orxonox", TclThreadManager::tcl_orxonox, Tcl::variadic());
     229        Tcl::interpreter* i = 0;
     230        i = new Tcl::interpreter(TclBind::getInstance().getTclLibPath());
     231
     232        i->def("query", TclThreadManager::tcl_query, Tcl::variadic());
    134233        i->def("execute", TclThreadManager::tcl_execute, Tcl::variadic());
    135234
    136235        std::string id = getConvertedValue<unsigned int, std::string>(threadID);
    137         i->eval("rename exit tclexit; proc exit {} { orxonox TclThreadManager destroy " + id + " }");
    138         i->eval("set threadid " + id);
    139         i->eval("redef_puts");
     236        try
     237        {
     238            i->eval("rename exit tclexit; proc exit {} { orxonox TclThreadManager destroy " + id + " }");
     239            i->eval("proc orxonox args { query " + id + " $args }");
     240            i->eval("set threadid " + id);
     241            i->eval("redef_puts");
     242        }
     243        catch (Tcl::tcl_error const &e)
     244        {
     245            COUT(1) << "Tcl error: " << e.what() << std::endl;
     246        }
     247        catch (std::exception const &e)
     248        {
     249            COUT(1) << "Error while creating Tcl-thread (" << id << "): " << e.what() << std::endl;
     250        }
    140251
    141252        return i;
     
    145256    {
    146257        this->IDcount_++;
    147         Tcl::interpreter* i = this->createTclInterpreter(this->IDcount_);
    148         boost::try_mutex* m = new boost::try_mutex;
    149         boost::thread*    t = new boost::thread(boost::bind(&tclThreadLoop, i, m, this->IDcount_));
    150         TclThread newthread = {i, t, m};
     258        TclThread* newthread = new TclThread;
     259        newthread->threadID_ = this->IDcount_;
     260        newthread->interpreter_ = this->createTclInterpreter(this->IDcount_);
     261        newthread->evalMutex_ = new boost::mutex;
     262        newthread->stateMutex_ = new boost::mutex;
     263        newthread->state_ = new TclThread::State(TclThread::Ready);
     264        newthread->thread_ = new boost::thread(boost::bind(&tclThreadLoop, newthread));
    151265        {
    152266            // mutex threads
     
    157271            // mutes threadqueues
    158272            boost::mutex::scoped_lock lock(this->threadQueuesMutex_);
    159             this->threadQueues_[this->IDcount_];
     273            this->threadQueues_[this->IDcount_] = std::pair<std::queue<std::string>, boost::condition*>(std::queue<std::string>(), new boost::condition());
    160274        }
    161275        return true;
     
    167281        boost::mutex::scoped_lock lock(this->threadsMutex_);
    168282
    169         std::map<unsigned int, TclThread>::iterator it = this->threads_.find(threadID);
     283        std::map<unsigned int, TclThread*>::iterator it = this->threads_.find(threadID);
    170284        if (it != this->threads_.end())
    171285        {
    172             delete (*it).second.interpreter_;
    173             delete (*it).second.thread_;
    174             delete (*it).second.mutex_;
     286            this->setState((*it).second, TclThread::Finished);
     287            (*it).second->thread_->timed_join(boost::posix_time::time_duration(0, 0, 0, 10));
     288
     289            delete (*it).second->interpreter_;
     290            delete (*it).second->thread_;
     291            delete (*it).second->evalMutex_;
     292            delete (*it).second->stateMutex_;
     293            delete (*it).second->state_;
     294            delete (*it).second;
    175295
    176296            this->threads_.erase(it);
     
    178298                // mutex threadqueues
    179299                boost::mutex::scoped_lock lock(this->threadQueuesMutex_);
    180                 this->threadQueues_.erase(threadID);
     300                std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::iterator it = this->threadQueues_.find(threadID);
     301                if (it != this->threadQueues_.end())
     302                {
     303                    delete (*it).second.second;
     304                    this->threadQueues_.erase(threadID);
     305                }
     306                else
     307                {
     308                    return false;
     309                }
    181310            }
    182311            return true;
     
    184313        else
    185314        {
    186             COUT(1) << "Error: No Tcl-thread with ID " << threadID << "." << std::endl;
     315            COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
    187316            return false;
    188317        }
     318    }
     319
     320    void TclThreadManager::setState(TclThread* tclThread, TclThread::State state)
     321    {
     322        // mutex state
     323        boost::mutex::scoped_lock lock(*tclThread->stateMutex_);
     324        *tclThread->state_ = state;
     325    }
     326
     327    TclThread::State TclThreadManager::getState(TclThread* tclThread)
     328    {
     329        // mutex state
     330        boost::mutex::scoped_lock lock(*tclThread->stateMutex_);
     331        TclThread::State state = *tclThread->state_;
     332        return state;
    189333    }
    190334
     
    194338        boost::mutex::scoped_lock lock(this->orxonoxQueueMutex_);
    195339
    196         while (this->orxonoxQueue_.size() == TCLTHREAD_MAX_QUEUE_LENGTH)
     340        while (this->orxonoxQueue_.size() >= TCLTHREAD_MAX_QUEUE_LENGTH)
    197341            this->orxonoxQueueCondition_.wait(lock);
    198342
     
    226370        boost::mutex::scoped_lock lock(this->threadQueuesMutex_);
    227371
    228         std::map<unsigned int, std::queue<std::string> >::iterator it = this->threadQueues_.find(threadID);
     372        std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::iterator it = this->threadQueues_.find(threadID);
    229373        if (it != this->threadQueues_.end())
    230374        {
    231             (*it).second.push(command);
     375            while ((*it).second.first.size() >= TCLTHREAD_MAX_QUEUE_LENGTH)
     376                (*it).second.second->wait(lock);
     377
     378            (*it).second.first.push(command);
    232379        }
    233380        else
    234381        {
    235             COUT(1) << "Error: No Tcl-thread with ID " << threadID << "." << std::endl;
     382            COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
    236383        }
    237384    }
     
    242389        boost::mutex::scoped_lock lock(this->threadQueuesMutex_);
    243390
    244         std::map<unsigned int, std::queue<std::string> >::iterator it = this->threadQueues_.find(threadID);
     391        std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::iterator it = this->threadQueues_.find(threadID);
    245392        if (it != this->threadQueues_.end())
    246393        {
    247             std::string command = (*it).second.front();
    248             (*it).second.pop();
     394            std::string command = (*it).second.first.front();
     395            (*it).second.first.pop();
    249396            return command;
    250397        }
    251398        else
    252399        {
    253             COUT(1) << "Error: No Tcl-thread with ID " << threadID << "." << std::endl;
     400            COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
    254401            return "";
    255402        }
     
    261408        boost::mutex::scoped_lock lock(this->threadQueuesMutex_);
    262409
    263         std::map<unsigned int, std::queue<std::string> >::iterator it = this->threadQueues_.find(threadID);
     410        std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::const_iterator it = this->threadQueues_.find(threadID);
    264411        if (it != this->threadQueues_.end())
    265412        {
    266             return (*it).second.empty();
     413            return (*it).second.first.empty();
    267414        }
    268415        else
    269416        {
    270             COUT(1) << "Error: No Tcl-thread with ID " << threadID << "." << std::endl;
     417            COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
    271418            return true;
    272419        }
     
    275422    std::string TclThreadManager::eval(const std::string& command)
    276423    {
    277         boost::mutex::scoped_lock lock(this->orxonoxEvalMutex_);
     424        // mutex orxstate
     425        boost::mutex::scoped_lock lock(this->orxonoxStateMutex_);
    278426
    279427        while (!this->isReady_)
     
    290438    std::string TclThreadManager::eval(unsigned int threadID, const std::string& command)
    291439    {
    292         // mutex threads
    293         boost::mutex::scoped_lock lock(this->threadsMutex_);
    294 
    295         std::map<unsigned int, TclThread>::iterator it = this->threads_.find(threadID);
    296         if (it != this->threads_.end())
    297         {
    298             boost::try_mutex::scoped_try_lock lock(*(*it).second.mutex_, boost::defer_lock_t());
    299             bool threadIsReady = false;
    300             try
    301             {
    302                 threadIsReady = lock.try_lock();
    303             }
    304             catch(boost::lock_error& e){ std::cout << "lockerror thread" << std::endl; }
    305 
    306             if (threadIsReady)
    307             {
    308                 try
    309                 {
     440        {
     441            // mutex query
     442            boost::mutex::scoped_lock lock(this->orxonoxQueryMutex_);
     443            this->isQuerying_ = true;
     444            this->queryID_ = threadID;
     445std::cout << "2_0\n";
     446        }
     447
     448        {
     449            // mutex threads
     450            boost::mutex::scoped_lock lock(this->threadsMutex_);
     451
     452            std::map<unsigned int, TclThread*>::iterator it = this->threads_.find(threadID);
     453            if (it != this->threads_.end())
     454            {
    310455std::cout << "2_1\n";
    311                     return (*it).second.interpreter_->eval(command);
    312                 }
    313                 catch (Tcl::tcl_error const &e)
     456                if (this->getState((*it).second) == TclThread::Ready)
    314457                {
    315458std::cout << "2_2\n";
    316                     COUT(1) << "Tcl error: " << e.what() << std::endl;
    317                 }
    318                 catch (std::exception const &e)
    319                 {
     459                    // mutex threadeval
     460                    boost::mutex::scoped_lock lock(*(*it).second->evalMutex_);
     461                    try
     462                    {
    320463std::cout << "2_3\n";
    321                     COUT(1) << "Error while executing tcl: " << e.what() << std::endl;
     464                        return (*it).second->interpreter_->eval(command);
     465                    }
     466                    catch (Tcl::tcl_error const &e)
     467                    {
     468                        COUT(1) << "Tcl error: " << e.what() << std::endl;
     469                    }
     470                    catch (std::exception const &e)
     471                    {
     472                        COUT(1) << "Error while executing Tcl: " << e.what() << std::endl;
     473                    }
     474    std::cout << "2_4\n";
     475                }
     476                else
     477                {
     478                    COUT(1) << "Error: Tcl-thread with ID " << threadID << " is not ready. Wait until it's finished or start a new thread." << std::endl;
    322479                }
    323480            }
    324481            else
    325482            {
    326                 COUT(1) << "Error: Tcl-thread with ID " << threadID << " is not ready. Wait until it's finished or start a new thread." << std::endl;
    327             }
    328         }
    329         else
    330         {
    331             COUT(1) << "Error: No Tcl-thread with ID " << threadID << "." << std::endl;
    332         }
     483                COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
     484            }
     485        }
     486
     487        {
     488            // mutex query
     489            boost::mutex::scoped_lock lock(this->orxonoxQueryMutex_);
     490            this->isQuerying_ = false;
     491            this->queryID_ = 0;
     492std::cout << "2_5\n";
     493        }
     494
    333495        return "";
    334496    }
     
    337499    {
    338500        {
    339             boost::mutex::scoped_lock lock(this->orxonoxEvalMutex_);
     501            // mutex orxstate
     502            boost::mutex::scoped_lock lock(this->orxonoxStateMutex_);
    340503            this->isReady_ = true;
    341504        }
     
    345508
    346509        {
    347             boost::mutex::scoped_lock lock(this->orxonoxEvalMutex_);
     510            // mutex orxstate
     511            boost::mutex::scoped_lock lock(this->orxonoxStateMutex_);
    348512            this->isReady_ = false;
    349513        }
     
    359523    }
    360524
    361     void tclThreadLoop(Tcl::interpreter* interpreter, boost::try_mutex* mutex, unsigned int threadID)
     525    void tclThreadLoop(TclThread* tclThread)
    362526    {
    363527        while (true)
    364528        {
    365             {
    366                 boost::try_mutex::scoped_try_lock lock(*mutex, boost::defer_lock_t());
    367                 bool threadIsReady = false;
     529            if (!TclThreadManager::getInstance().isEmpty(tclThread->threadID_))
     530            {
     531                std::cout << "a\n";
     532                TclThreadManager::getInstance().setState(tclThread, TclThread::Busy);
     533//                if (!TclThreadManager::getInstance().isEmpty(tclThread->threadID_))
     534                {
     535                    try
     536                    {
     537                        std::cout << "c\n";
     538                        throw std::exception();
     539                        std::cout << "d\n";
     540                    }
     541                    catch (...)
     542                    {
     543                        std::cout << "e\n";
     544                    }
     545                }
     546                TclThreadManager::getInstance().setState(tclThread, TclThread::Ready);
     547                std::cout << "f\n";
     548
     549//                boost::this_thread::yield();
     550//                if (TclThreadManager::getInstance().getState(tclThread) == TclThread::Finished)
     551//                    return;
     552            }
     553        }
     554
     555/*        while (true)
     556        {
     557            TclThreadManager::getInstance().setState(tclThread, TclThread::Busy);
     558            while (!TclThreadManager::getInstance().isEmpty(tclThread->threadID_))
     559            {
    368560                try
    369561                {
    370                     threadIsReady = lock.try_lock();
    371                 }
    372                 catch(boost::lock_error& e){ std::cout << "lockerror thread" << std::endl; }
    373 
    374                 if (threadIsReady)
    375                 {
    376                     while (!TclThreadManager::getInstance().isEmpty(threadID))
    377                     {
    378                         try
    379                         {
    380 std::cout << "1\n";
    381 std::cout << threadID << std::endl;
    382 std::string temp = TclThreadManager::getInstance().popCommandFront(threadID);
    383 std::cout << temp << std::endl;
    384                             interpreter->eval(temp);
    385 std::cout << "2\n";
    386                         }
    387                         catch (Tcl::tcl_error const &e)
    388                         {
    389 std::cout << "3\n";
    390                             TclThreadManager::getInstance().pushCommandBack("error Tcl error (thread " + getConvertedValue<unsigned int, std::string>(threadID) + "): " + e.what());
    391                         }
    392                         catch (std::exception const &e)
    393                         {
    394 std::cout << "4\n";
    395                             TclThreadManager::getInstance().pushCommandBack("error Error while executing tcl (thread " + getConvertedValue<unsigned int, std::string>(threadID) + "): " + e.what());
    396                         }
    397                         catch (...)
    398                         {
    399 std::cout << "5\n";
    400                             TclThreadManager::getInstance().pushCommandBack("error Error while executing tcl (thread " + getConvertedValue<unsigned int, std::string>(threadID) + ").");
    401                         }
    402                     }
    403                 }
    404             }
    405 
    406             while (TclThreadManager::getInstance().isEmpty(threadID))
     562std::cout << "1_1\n";
     563                    // mutex threadeval
     564                    boost::mutex::scoped_lock lock(*tclThread->evalMutex_);
     565                    tclThread->interpreter_->eval(TclThreadManager::getInstance().popCommandFront(tclThread->threadID_));
     566std::cout << "1_2\n";
     567                }
     568                catch (Tcl::tcl_error const &e)
     569                {
     570                    TclThreadManager::getInstance().pushCommandBack("error Tcl error (thread " + getConvertedValue<unsigned int, std::string>(tclThread->threadID_) + "): " + e.what());
     571                }
     572                catch (std::exception const &e)
     573                {
     574                    TclThreadManager::getInstance().pushCommandBack("error Error while executing Tcl (thread " + getConvertedValue<unsigned int, std::string>(tclThread->threadID_) + "): " + e.what());
     575                }
     576std::cout << "1_4\n";
     577            }
     578            TclThreadManager::getInstance().setState(tclThread, TclThread::Ready);
     579
     580            while (TclThreadManager::getInstance().isEmpty(tclThread->threadID_))
     581            {
    407582                boost::this_thread::yield();
    408         }
     583                if (TclThreadManager::getInstance().getState(tclThread) == TclThread::Finished)
     584                    return;
     585            }
     586        }*/
    409587    }
    410588}
  • code/branches/console/src/core/TclThreadManager.h

    r1230 r1247  
    4545    struct TclThread
    4646    {
     47        unsigned int threadID_;
    4748        Tcl::interpreter* interpreter_;
    4849        boost::thread* thread_;
    49         boost::try_mutex* mutex_;
     50        boost::mutex* evalMutex_;
     51        boost::mutex* stateMutex_;
     52        enum State
     53        {
     54            Ready,
     55            Busy,
     56            Finished,
     57            Error
     58        }* state_;
    5059    };
    5160
     
    6069            static void execute(unsigned int threadID, const std::string& command);
    6170            static std::string query(unsigned int threadID, const std::string& command);
     71            static void status();
     72            static void dump(unsigned int threadID);
    6273
     74            static std::string tcl_query(int id, Tcl::object const &args);
    6375            static void tcl_execute(Tcl::object const &args);
    64             static std::string tcl_orxonox(Tcl::object const &args);
    6576
    6677            Tcl::interpreter* createTclInterpreter(unsigned int threadID) const;
    6778            bool createTclThread();
    6879            bool destroyTclThread(unsigned int threadID);
     80
     81            void setState(TclThread* tclThread, TclThread::State state);
     82            TclThread::State getState(TclThread* tclThread);
    6983
    7084            void pushCommandBack(const std::string& command);
     
    8599
    86100            bool isReady_;
     101            bool isQuerying_;
     102            unsigned int queryID_;
    87103
    88104            unsigned int IDcount_;
    89             std::map<unsigned int, TclThread> threads_;
    90             std::map<unsigned int, std::queue<std::string> > threadQueues_;
     105            std::map<unsigned int, TclThread*> threads_;
     106            std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> > threadQueues_;
    91107            std::queue<std::string> orxonoxQueue_;
    92108
    93             boost::mutex orxonoxQueueMutex_;
    94             boost::mutex threadQueuesMutex_;
    95             boost::mutex threadsMutex_;
    96             boost::mutex orxonoxEvalMutex_;
     109            boost::try_mutex orxonoxQueueMutex_;
     110            boost::try_mutex threadQueuesMutex_;
     111            boost::try_mutex threadsMutex_;
     112            boost::try_mutex orxonoxStateMutex_;
     113            boost::try_mutex orxonoxQueryMutex_;
    97114
    98115            boost::condition orxonoxQueueCondition_;
     
    100117    };
    101118
    102     _CoreExport void tclThreadLoop(Tcl::interpreter* interpreter, boost::try_mutex* mutex, unsigned int threadID);
     119    _CoreExport void tclThreadLoop(TclThread* tclThread);
    103120}
    104121
Note: See TracChangeset for help on using the changeset viewer.