Belle II Software development
MMutex.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#ifndef _Belle2_MMutex_h
9#define _Belle2_MMutex_h
10
11#include <pthread.h>
12
13#ifdef __CINT__
14#undef __GNUC__
15#define _SYS__SELECT_H_
16struct pthread_cond_t;
17struct pthread_mutex_t;
18#endif
19
20namespace Belle2 {
26 class MMutex {
27
28 friend class MCond;
29
30 public:
31 static size_t size() { return sizeof(pthread_mutex_t); }
32
33 // constructors and destructor
34 public:
35 MMutex();
36 explicit MMutex(void*);
37 MMutex(const MMutex&);
38 ~MMutex();
39
40 // member functions;
41 public:
42 bool init(void*);
43 bool init();
44 bool set(void*);
45 bool lock();
46 bool trylock();
47 bool unlock();
48 bool destroy();
49
50 public:
51 const MMutex& operator=(const MMutex&);
52
53 // data members;
54 private:
55 pthread_mutex_t* m_mu;
56
57 };
58
60};
61
62#endif
Abstract base class for different kinds of events.