~ubuntu-branches/debian/sid/gsmartcontrol/sid

« back to all changes in this revision

Viewing changes to src/hz/sync_policy_pthread.h

  • Committer: Package Import Robot
  • Author(s): Giuseppe Iuculano
  • Date: 2013-05-31 11:41:52 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130531114152-5ljhkuswwpt4kdwo
Tags: 0.8.7-1
* [314881d] Updated debian/watch
* [18ebada] Imported Upstream version 0.8.7
* [c2a1f1b] debian/rules: Provide build-arch and build-indep
* [d3036a4] Enabled Hardening Options
* [2edfb87] Refreshed patches and removed patches apllied upstream
* [ac3b953] Bump to standard versions 3.9.4
* [292c276] Remove quilt from depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**************************************************************************
2
2
 Copyright:
3
 
      (C) 2008 - 2011  Alexander Shaduri <ashaduri 'at' gmail.com>
 
3
      (C) 2008 - 2012  Alexander Shaduri <ashaduri 'at' gmail.com>
4
4
 License: See LICENSE_zlib.txt file
5
5
***************************************************************************/
6
6
 
24
24
#include "sync.h"
25
25
 
26
26
 
27
 
// Posix Threads-based policy.
28
 
 
29
 
// Note: RecMutex assumes that pthread_mutexattr_settype
30
 
// and PTHREAD_MUTEX_RECURSIVE work on current platform.
31
 
 
32
 
// NOTE: This file requires UNIX98 support, enabled via _XOPEN_SOURCE >= 500
33
 
// in glibc. Solaris doesn't need any additional feature macros.
34
 
 
35
 
// Configuration macros:
36
 
// This enables PTHREAD_MUTEX_ERRORCHECK flag on
37
 
// non-recursive mutexes, which may perform some additional
38
 
// checking on some systems.
 
27
/**
 
28
\file
 
29
Posix Threads-based policy.
 
30
 
 
31
Note: RecMutex assumes that pthread_mutexattr_settype
 
32
and PTHREAD_MUTEX_RECURSIVE work on current platform.
 
33
 
 
34
NOTE: This file requires UNIX98 support, enabled via _XOPEN_SOURCE >= 500
 
35
in glibc. Solaris doesn't need any additional feature macros.
 
36
 
 
37
Configuration macros:
 
38
This enables PTHREAD_MUTEX_ERRORCHECK flag on
 
39
non-recursive mutexes, which may perform some additional
 
40
checking on some systems.
 
41
*/
39
42
#ifndef HZ_SYNC_PTHREAD_ERROR_CHECKS
40
43
        #define HZ_SYNC_PTHREAD_ERROR_CHECKS 1
41
44
#endif
47
50
 
48
51
namespace internal {
49
52
 
 
53
        /// Throw exception on pthread error
50
54
        inline void sync_pthread_throw_exception(const std::string& msg, int errno_value = 0)
51
55
        {
52
56
                if (errno_value == 0) {
60
64
 
61
65
 
62
66
 
63
 
// Attempting to destroy a locked mutex results in undefined behavior.
 
67
/// C++ wrapper for pthreads mutex.
 
68
/// Attempting to destroy a locked mutex results in undefined behavior.
64
69
class MutexPthread : public hz::noncopyable {
65
70
        public:
66
71
 
151
156
 
152
157
 
153
158
 
 
159
/// C++ wrapper for pthreads recursive mutex.
154
160
class RecMutexPthread : public hz::noncopyable {
155
161
        public:
156
162
 
260
266
 
261
267
 
262
268
 
 
269
/// C++ wrapper for pthreads RW lock.
263
270
class RWMutexPthread : public hz::noncopyable {
264
271
        public:
265
272
 
335
342
 
336
343
 
337
344
 
338
 
// Native type notes: none.
339
 
 
340
 
 
 
345
/// Pthreads policy.
 
346
/// Native type notes: none.
341
347
struct SyncPolicyPthread : public SyncScopedLockProvider<SyncPolicyPthread> {
342
348
 
343
349
        // Types:
346
352
        typedef Mutex::native_type NativeMutex;
347
353
 
348
354
        typedef RecMutexPthread RecMutex;
349
 
        typedef RecMutex::native_type NativeRecMutex;  // same type as NativeMutex
 
355
        typedef RecMutex::native_type NativeRecMutex;  ///< same type as NativeMutex
350
356
 
351
357
        typedef RWMutexPthread RWMutex;
352
358
        typedef RWMutex::native_type NativeRWMutex;