Panda3D

conditionVarPosixImpl.I
Go to the documentation of this file.
1 /**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file conditionVarPosixImpl.I
10 * @author drose
11 * @date 2006-02-10
12 */
13
14 /**
15 *
16 */
17 INLINE ConditionVarPosixImpl::
18 ConditionVarPosixImpl(MutexPosixImpl &mutex) :
19 _mutex(mutex)
20 {
21 TAU_PROFILE("ConditionVarPosixImpl::ConditionVarPosixImpl()", " ", TAU_USER);
22 int result = pthread_cond_init(&_cvar, nullptr);
23 nassertv(result == 0);
24 }
25
26 /**
27 *
28 */
29 INLINE ConditionVarPosixImpl::
30 ~ConditionVarPosixImpl() {
31 TAU_PROFILE("ConditionVarPosixImpl::~ConditionVarPosixImpl()", " ", TAU_USER);
32 int result = pthread_cond_destroy(&_cvar);
33 nassertv(result == 0);
34 }
35
36 /**
37 *
38 */
39 INLINE void ConditionVarPosixImpl::
40 wait() {
41 TAU_PROFILE("ConditionVarPosixImpl::wait()", " ", TAU_USER);
42 int result = pthread_cond_wait(&_cvar, &_mutex._lock);
43 #ifndef NDEBUG
44 if (result != 0) {
45 pipeline_cat.error()
46 << "Unexpected error " << result << " from pthread_cond_wait()\n";
47 }
48 #endif
49 }
50
51 /**
52 *
53 */
54 INLINE void ConditionVarPosixImpl::
55 notify() {
56 TAU_PROFILE("ConditionVarPosixImpl::notify()", " ", TAU_USER);
57 int result = pthread_cond_signal(&_cvar);
58 nassertv(result == 0);
59 }
60
61 /**
62 *
63 */
64 INLINE void ConditionVarPosixImpl::
65 notify_all() {
66 TAU_PROFILE("ConditionVarPosixImpl::notify()", " ", TAU_USER);
67 int result = pthread_cond_broadcast(&_cvar);
68 nassertv(result == 0);
69 }