Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/water/src/lib/util/threading.h @ 7798

Last change on this file since 7798 was 7737, checked in by bensch, 19 years ago

Using MultiLine-Text in the Shell. This is much faster, and Nicer :)

File size: 1.1 KB
Line 
1/*!
2 * @file threading.h
3 * @brief Definition of Thread Classes.
4 *
5 * These are mainly Classes, that are used for wrapping around SDL_thread
6*/
7
8#ifndef _THREADING_H
9#define _THREADING_H
10
11#ifdef HAVE_SDL_H
12 #include <SDL_thread.h>
13#else
14 #include <SDL/SDL_thread.h>
15#endif
16
17namespace OrxThread
18{
19  //! A class for Wrapping Threads
20  class Thread
21  {
22
23  public:
24    Thread();
25    virtual ~Thread();
26
27
28  private:
29
30  };
31
32  class Mutex
33  {
34  public:
35    Mutex() {  this->mutex = SDL_CreateMutex(); };
36    ~Mutex() { SDL_DestroyMutex(this->mutex); }
37
38    void lock() { SDL_mutexP(mutex); };
39    void unlock() { SDL_mutexV(mutex); };
40
41    SDL_mutex* getMutex() const { return this->mutex; };
42  private:
43    SDL_mutex* mutex;
44  };
45
46  //! A Class that locks a Mutex within its scope
47  class MutexLock
48  {
49  public:
50    //! Locks the Mutex mutex in this Scope.
51    MutexLock(Mutex* mutex) { SDL_mutexP(mutex->getMutex()); this->mutex = mutex; };
52    ~MutexLock() { SDL_mutexV(mutex->getMutex()); };
53  private:
54    Mutex* mutex;         //!< The Mutex to lock.
55  };
56}
57
58#endif /* _THREADING_H */
Note: See TracBrowser for help on using the repository browser.