Panda3D
panda
src
pipeline
conditionVarDirect.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 conditionVarDirect.I
10
* @author drose
11
* @date 2006-02-13
12
*/
13
14
/**
15
* You must pass in a Mutex to the condition variable constructor. This mutex
16
* may be shared by other condition variables, if desired. It is the caller's
17
* responsibility to ensure the Mutex object does not destruct during the
18
* lifetime of the condition variable.
19
*/
20
INLINE
ConditionVarDirect::
21
ConditionVarDirect
(
MutexDirect
&mutex) :
22
_mutex(mutex),
23
_impl(mutex._impl)
24
{
25
}
26
27
/**
28
* Returns the mutex associated with this condition variable.
29
*/
30
INLINE
MutexDirect
&
ConditionVarDirect::
31
get_mutex
()
const
{
32
return
_mutex;
33
}
34
35
/**
36
* Waits on the condition. The caller must already be holding the lock
37
* associated with the condition variable before calling this function.
38
*
39
* wait() will release the lock, then go to sleep until some other thread
40
* calls notify() on this condition variable. At that time at least one
41
* thread waiting on the same ConditionVarDirect will grab the lock again, and
42
* then return from wait().
43
*
44
* It is possible that wait() will return even if no one has called notify().
45
* It is the responsibility of the calling process to verify the condition on
46
* return from wait, and possibly loop back to wait again if necessary.
47
*
48
* Note the semantics of a condition variable: the mutex must be held before
49
* wait() is called, and it will still be held when wait() returns. However,
50
* it will be temporarily released during the wait() call itself.
51
*/
52
INLINE
void
ConditionVarDirect::
53
wait
() {
54
TAU_PROFILE(
"ConditionVarDirect::wait()"
,
" "
, TAU_USER);
55
_impl.wait();
56
}
57
58
/**
59
* Waits on the condition, with a timeout. The function will return when the
60
* condition variable is notified, or the timeout occurs. There is no way to
61
* directly tell which happened, and it is possible that neither in fact
62
* happened (spurious wakeups are possible).
63
*
64
* See wait() with no parameters for more.
65
*/
66
void
ConditionVarDirect::
67
wait
(
double
timeout) {
68
TAU_PROFILE(
"ConditionVarDirect::wait(double)"
,
" "
, TAU_USER);
69
_impl.wait(timeout);
70
}
71
72
/**
73
* Informs one of the other threads who are currently blocked on wait() that
74
* the relevant condition has changed. If multiple threads are currently
75
* waiting, at least one of them will be woken up, although there is no way to
76
* predict which one. It is possible that more than one thread will be woken
77
* up.
78
*
79
* The caller must be holding the mutex associated with the condition variable
80
* before making this call, which will not release the mutex.
81
*
82
* If no threads are waiting, this is a no-op: the notify event is lost.
83
*/
84
INLINE
void
ConditionVarDirect::
85
notify
() {
86
TAU_PROFILE(
"ConditionVarDirect::notify()"
,
" "
, TAU_USER);
87
_impl.notify();
88
}
ConditionVarDirect::notify
void notify()
Informs one of the other threads who are currently blocked on wait() that the relevant condition has ...
Definition:
conditionVarDirect.I:85
ConditionVarDirect::get_mutex
MutexDirect & get_mutex() const
Returns the mutex associated with this condition variable.
Definition:
conditionVarDirect.I:31
ConditionVarDirect::ConditionVarDirect
ConditionVarDirect(MutexDirect &mutex)
You must pass in a Mutex to the condition variable constructor.
Definition:
conditionVarDirect.I:21
MutexDirect
This class implements a standard mutex by making direct calls to the underlying implementation layer.
Definition:
mutexDirect.h:30
ConditionVarDirect::wait
void wait()
Waits on the condition.
Definition:
conditionVarDirect.I:53
Generated on Mon Sep 14 2020 15:07:05 for Panda3D by
1.8.20