source: mainline/uspace/lib/cpp/src/condition_variable.cpp@ 8624d1f

Last change on this file since 8624d1f was b57ba05, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Update headers in C++ files

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 * SPDX-FileCopyrightText: 2019 Jaroslav Jindrak
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <cassert>
8#include <condition_variable>
9
10namespace std
11{
12 condition_variable::condition_variable()
13 : cv_{}
14 {
15 aux::threading::condvar::init(cv_);
16 }
17
18 condition_variable::~condition_variable()
19 { /* DUMMY BODY */ }
20
21 void condition_variable::notify_one() noexcept
22 {
23 aux::threading::condvar::signal(cv_);
24 }
25
26 void condition_variable::notify_all() noexcept
27 {
28 aux::threading::condvar::broadcast(cv_);
29 }
30
31 void condition_variable::wait(unique_lock<mutex>& lock)
32 {
33 if (lock.owns_lock())
34 aux::threading::condvar::wait(cv_, *lock.mutex()->native_handle());
35 }
36
37 condition_variable::native_handle_type condition_variable::native_handle()
38 {
39 return &cv_;
40 }
41
42 condition_variable_any::condition_variable_any()
43 : cv_{}
44 {
45 aux::threading::condvar::init(cv_);
46 }
47
48 condition_variable_any::~condition_variable_any()
49 { /* DUMMY BODY */ }
50
51 void condition_variable_any::notify_one() noexcept
52 {
53 aux::threading::condvar::signal(cv_);
54 }
55
56 void condition_variable_any::notify_all() noexcept
57 {
58 aux::threading::condvar::broadcast(cv_);
59 }
60
61 condition_variable_any::native_handle_type condition_variable_any::native_handle()
62 {
63 return &cv_;
64 }
65
66 void notify_all_at_thread_exit(condition_variable&, unique_lock<mutex>&)
67 {
68 // TODO: implement
69 __unimplemented();
70 }
71}
Note: See TracBrowser for help on using the repository browser.