CPN
Computational Process Networks
PthreadConditionAttr.cc
Go to the documentation of this file.
1 //=============================================================================
2 // PthreadConditionAttr 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 #ifdef EXTERNAL_TEMPLATES
23 # pragma implementation "PthreadConditionAttr.h"
24 #endif
25 
27 #ifdef _POSIX_THREADS
28 
29 
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
33 {
34  TrapError(pthread_condattr_init(&condAttr));
35 }
36 
37 
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
41 {
42  try {
43  TrapError(pthread_condattr_destroy(&condAttr));
44  } catch (...) {
45  std::terminate();
46  }
47 }
48 
49 
50 #ifdef _POSIX_THREAD_PROCESS_SHARED
51 //-----------------------------------------------------------------------------
52 int PthreadConditionAttr::ProcessShared(void)
53 //-----------------------------------------------------------------------------
54 { int pshared;
55  TrapError(pthread_condattr_getpshared(&condAttr, &pshared));
56  return pshared == PTHREAD_PROCESS_SHARED;
57 }
58 
59 
60 //-----------------------------------------------------------------------------
61 PthreadConditionAttr& PthreadConditionAttr::ProcessShared(int pshared)
62 //-----------------------------------------------------------------------------
63 { TrapError(pthread_condattr_setpshared(&condAttr, pshared ?
64  PTHREAD_PROCESS_SHARED : PTHREAD_PROCESS_PRIVATE));
65  return *this;
66 }
67 #endif
68 
69 
70 #endif
pthread_condattr_t condAttr
void TrapError(int result)