File: mutex.h

package info (click to toggle)
meshlab 1.3.2%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 21,060 kB
  • ctags: 33,549
  • sloc: cpp: 224,813; ansic: 8,170; xml: 119; makefile: 80
file content (51 lines) | stat: -rwxr-xr-x 607 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef MT_MUTEX_H
#define MT_MUTEX_H

#include "base.h"

#include <pthread.h>

namespace mt
{

class condition;

class mutex
{
	MT_PREVENT_COPY(mutex)

	public:

		typedef mutex this_type;
		typedef void  base_type;

		mutex(void)
		{
			pthread_mutex_init(&(this->m), 0);
		}

		~mutex(void)
		{
			pthread_mutex_destroy(&(this->m));
		}

		void lock(void)
		{
			pthread_mutex_lock(&(this->m));
		}

		void unlock(void)
		{
			pthread_mutex_unlock(&(this->m));
		}

	private:

		friend class condition;

		pthread_mutex_t m;
};

}

#endif // MT_MUTEX_H