The Pedigree Project  0.1
Mutex.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef MUTEX_H
21 #define MUTEX_H
22 
23 #ifdef STANDALONE_MUTEXES
24 
25 #include "pedigree/kernel/processor/types.h"
26 
27 class Mutex
28 {
29  public:
30  Mutex(bool bLocked = false);
31  ~Mutex();
32 
33  bool acquire();
34  bool tryAcquire();
35  void release();
36 
37  ssize_t getValue();
38 
39  void *getPrivate() const
40  {
41  return m_Private;
42  }
43 
44  private:
45  void *m_Private;
46 };
47 
48 #else
49 
50 #ifdef THREADS
51 
52 #include "pedigree/kernel/compiler.h"
53 #include "pedigree/kernel/process/Semaphore.h"
54 
59 {
60  public:
62  Mutex(bool bLocked = false);
64  ~Mutex();
65 };
66 
67 #endif // THREADS
68 
69 #endif // STANDALONE_MUTEXES
70 
71 #endif // MUTEX_H
bool acquire(size_t n=1, size_t timeoutSecs=0, size_t timeoutUsecs=0)
Definition: Semaphore.h:62
Definition: Mutex.h:58
Mutex(bool bLocked=false)
Definition: Mutex.cc:25
~Mutex()
Definition: Mutex.cc:29
ssize_t getValue()
Definition: Semaphore.cc:318
void release(size_t n=1)
Definition: Semaphore.cc:239
bool tryAcquire(size_t n=1)
Definition: Semaphore.cc:223