File: conditionany.yo

package info (click to toggle)
c%2B%2B-annotations 13.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,576 kB
  • sloc: cpp: 25,297; makefile: 1,523; ansic: 165; sh: 126; perl: 90; fortran: 27
file content (66 lines) | stat: -rw-r--r-- 3,237 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Different from the class tt(condition_variable) the class
    hi(condition_variable_any)tt(std::condition_variable_any) can be used with
any (e.g., user supplied) lock type, and not just with the stl-provided
tt(unique_lock<mutex>).

Before using the class tt(condition_variable_any) the tthi(condition_variable)
header file must be included.

The functionality that is offered by tt(condition_variable_any) is identical
to the functionality offered by the class tt(condition_variable), albeit that
the lock-type that is used by tt(condition_variable_any) is not
predefined. The class tt(condition_variable_any) therefore requires the
specification of the lock-type that must be used by its objects.

In the interface shown below this lock-type is referred to as
hi(lock)tt(Lock). Most of tt(condition_variable_any's) members are defined as
member templates, defining a tt(Lock) type as one of its parameters. The
requirements of these lock-types are identical to those of the stl-provided
tt(unique_lock), and user-defined lock-type implementations should provide at
least the interface and semantics that is also provided by tt(unique_lock).

This section merely presents the interface of the class
tt(condition_variable_any). As its interface offers the same members as
tt(condition_variable) (allowing, where applicable, passing any lock-type
instead of just tt(unique_lock) to corresponding members), the reader is
referred to the previous section for a description of the semantics of the
class members.

Like tt(condition_variable), the class tt(condition_variable_any) only
offers a default constructor. No copy constructor or overloaded assignment
operator is provided.

Also, like tt(condition_variable), the class's destructor requires that no
thread is blocked by the current thread. This implies that all other (waiting)
threads must have been notified; those threads may, however, subsequently
block on the lock specified in their tt(wait) calls.

Note that, in addition to tt(Lock), the types tt(Clock, Duration, Period,
Predicate,) and tt(Rep) are template types, defined just like the identically
named types mentioned in the previous section.

Assuming that tt(MyMutex) is a user defined mutex type, and that tt(MyLock) is
a user defined lock-type (cf. section ref(LOCKS) for details about
lock-types), then a tt(condition_variable_any) object can be defined and used
like this:
        verb(    MyMutex mut;
    MyLock<MyMutex> ul(mut);
    condition_variable_any cva;

    cva.wait(ul);)

These are the class tt(condition_variable_any's) members:
    itemization(
    itht(notify_one)(void notify_one() noexcept;)
    itht(notify_all)(void notify_all() noexcept;)
    itht(wait)(void wait(Lock& lock);)
    itt(void wait(Lock& lock, Predicate pred);)
    itht(wait_until)(cv_status wait_until(Lock& lock, const
        chrono::time_point<Clock, Duration>& absTime);)
    itt(bool wait_until(Lock& lock, const chrono::time_point<Clock, Duration>&
        absTime, Predicate pred);) 
    itht(wait_for)(cv_status wait_for(Lock& lock, const chrono::duration<Rep,
        Period>& relTime);) 
    itt(bool wait_for(Lock& lock, const chrono::duration<Rep, Period>&
        relTime,))linebreak() tt(Predicate pred); 
    )