File: condition.h

package info (click to toggle)
meshlab 2020.09%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 45,124 kB
  • sloc: cpp: 400,238; ansic: 31,952; javascript: 1,578; sh: 387; yacc: 238; lex: 139; python: 86; makefile: 29
file content (53 lines) | stat: -rwxr-xr-x 698 bytes parent folder | download | duplicates (6)
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
52
53
#ifndef MT_CONDITION_H
#define MT_CONDITION_H

#include "base.h"
#include "mutex.h"

#include <pthread.h>

namespace mt
{

class condition
{
	MT_PREVENT_COPY(condition)

	public:

		typedef condition this_type;
		typedef void      base_type;

		condition(void)
		{
			pthread_cond_init(&(this->c), 0);
		}

		~condition(void)
		{
			pthread_cond_destroy(&(this->c));
		}

		void signal(void)
		{
			pthread_cond_signal(&(this->c));
		}

		void broadcast(void)
		{
			pthread_cond_broadcast(&(this->c));
		}

		void wait(mutex & m)
		{
			pthread_cond_wait(&(this->c), &(m.m));
		}

	private:

		pthread_cond_t c;
};

}

#endif // MT_CONDITION_H