CPN
Computational Process Networks
PthreadMutexAttr.h
Go to the documentation of this file.
1 //=============================================================================
2 // PthreadMutexAttr class
3 //-----------------------------------------------------------------------------
4 // POSIX Pthread class library
5 // Copyright (C) 1997-1999 The University of Texas
6 //
7 // This library is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU Library General Public License as published
9 // by the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Library General Public License for more details.
16 //
17 // The GNU Public License is available in the file LICENSE, or you
18 // can write to the Free Software Foundation, Inc., 59 Temple Place -
19 // Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
20 // World Wide Web at http://www.fsf.org.
21 //=============================================================================
22 
23 
24 #ifndef PthreadMutexAttr_h
25 #define PthreadMutexAttr_h
26 #pragma once
27 
28 #ifdef EXTERNAL_TEMPLATES
29 # pragma interface
30 #endif
31 #include <cpn/common.h>
33 #ifdef _POSIX_THREADS
34 
36 
37 
39  public:
40  PthreadMutexAttr(void);
41  ~PthreadMutexAttr(void);
42  operator pthread_mutexattr_t* (void) { return &theAttr; }
43  operator const pthread_mutexattr_t* (void) const { return &theAttr; }
44 
45  #if (defined(_POSIX_THREAD_PRIO_PROTECT) && (_POSIX_THREAD_PRIO_PROTECT+0>0)) \
46  || (defined(_POSIX_THREAD_PRIO_INHERIT) && (_POSIX_THREAD_PRIO_INHERIT+0>0))
47  int UsingNoPriorityProtocol() { return Protocol() == POSIX_PRIO_NONE; }
48  PthreadMutexAttr& NoPriorityProtocol() { return Protocol(POSIX_PRIO_NONE); }
49  #endif
50 
51  #if defined(_POSIX_THREAD_PRIO_PROTECT) && (_POSIX_THREAD_PRIO_PROTECT+0>0)
52  int PriorityCeiling(void);
53  int UsingPriorityCeiling(void) { return Protocol() == POSIX_PRIO_PROTECT; }
54  PthreadMutexAttr& PriorityCeiling(int ceiling);
55  #endif
56 
57  #if defined(_POSIX_THREAD_PRIO_INHERIT) && (_POSIX_THREAD_PRIO_INHERIT+0>0)
58  PthreadMutexAttr& PriorityInheritance() { return Protocol(POSIX_PRIO_INHERIT); }
59  int UsingPriorityInheritance() { return Protocol() == POSIX_PRIO_INHERIT; }
60  #endif
61 
62  #if defined(_POSIX_THREAD_PROCESS_SHARED) && (_POSIX_THREAD_PROCESS_SHARED+0>0)
63  int ProcessShared(void);
64  PthreadMutexAttr& ProcessShared(int pshared);
65  #endif
66 
67  private:
68  pthread_mutexattr_t theAttr;
69 
70  #if (defined(_POSIX_THREAD_PRIO_PROTECT) && (_POSIX_THREAD_PRIO_PROTECT+0>0)) \
71  || (defined(_POSIX_THREAD_PRIO_INHERIT) && (_POSIX_THREAD_PRIO_INHERIT+0>0))
72  int Protocol(void);
73  PthreadMutexAttr& Protocol(int protocol);
74  #endif
75 
76  friend class PthreadMutex;
77 };
78 
79 
80 #endif
81 #endif
#define POSIX_PRIO_NONE
Definition: PthreadDefs.h:65
#define POSIX_PRIO_PROTECT
Definition: PthreadDefs.h:67
#define POSIX_PRIO_INHERIT
Definition: PthreadDefs.h:66
pthread_mutexattr_t theAttr