1 // BotThreading.C -*- C++ -*-
2 // Copyright (c) 2008 Clinton Ebadi
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 #include "BotThreading.H"
28 pthread_t self = pthread_self ();
29 std::cerr << "Mutex Init..."
30 << " Mutex: " << &mutex
31 << " Thread: " << &self
33 pthread_mutex_init (&mutex, 0);
36 BotMutex::~BotMutex ()
38 pthread_t self = pthread_self ();
39 std::cerr << "Mutex Destroy..."
40 << " Mutex: " << &mutex
41 << " Thread: " << &self
43 pthread_mutex_destroy (&mutex);
46 void BotMutex::lock ()
48 pthread_t self = pthread_self ();
49 std::cerr << "< Mutex Lock..."
50 << " Mutex: " << &mutex
51 << " Thread: " << &self
53 pthread_mutex_lock (&mutex);
56 void BotMutex::unlock ()
58 pthread_t self = pthread_self ();
59 std::cerr << "> Mutex Unlock..."
60 << " Mutex: " << &mutex
61 << " Thread: " << &self
63 pthread_mutex_unlock (&mutex);
66 #else // non threaded noops
71 BotMutex::~BotMutex ()
74 void BotMutex::lock ()
77 void BotMutex::unlock ()
82 BotLock::BotLock (BotMutex & m)
85 pthread_t self = pthread_self ();
86 std::cerr << "Lock Init..."
88 << " Mutex: " << &mutex
89 << " Thread: " << &self
96 pthread_t self = pthread_self ();
97 std::cerr << "Lock Destroy..."
99 << " Mutex: " << &mutex
100 << " Thread: " << &self