2
Copyright (c) 2010-2011 250bpm s.r.o.
3
Copyright (c) 2007-2009 iMatix Corporation
4
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
6
This file is part of 0MQ.
8
0MQ is free software; you can redistribute it and/or modify it under
9
the terms of the GNU Lesser General Public License as published by
10
the Free Software Foundation; either version 3 of the License, or
11
(at your option) any later version.
13
0MQ is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU Lesser General Public License for more details.
18
You should have received a copy of the GNU Lesser General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
#ifndef __ZMQ_MUTEX_HPP_INCLUDED__
23
#define __ZMQ_MUTEX_HPP_INCLUDED__
25
#include "platform.hpp"
28
// Mutex class encapsulates OS mutex in a platform-independent way.
30
#ifdef ZMQ_HAVE_WINDOWS
32
#include "windows.hpp"
42
InitializeCriticalSection (&cs);
47
DeleteCriticalSection (&cs);
52
EnterCriticalSection (&cs);
57
LeaveCriticalSection (&cs);
64
// Disable copy construction and assignment.
65
mutex_t (const mutex_t&);
66
void operator = (const mutex_t&);
83
int rc = pthread_mutex_init (&mutex, NULL);
90
int rc = pthread_mutex_destroy (&mutex);
97
int rc = pthread_mutex_lock (&mutex);
102
inline void unlock ()
104
int rc = pthread_mutex_unlock (&mutex);
111
pthread_mutex_t mutex;
113
// Disable copy construction and assignment.
114
mutex_t (const mutex_t&);
115
const mutex_t &operator = (const mutex_t&);