1 // <condition_variable> -*- C++ -*-
3 // Copyright (C) 2008 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING. If not, write to
18 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 // Boston, MA 02110-1301, USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 /** @file condition_variable
31 * This is a Standard C++ Library header.
34 #ifndef _GLIBCXX_CONDITION_VARIABLE
35 #define _GLIBCXX_CONDITION_VARIABLE 1
37 #pragma GCC system_header
39 #ifndef __GXX_EXPERIMENTAL_CXX0X__
40 # include <c++0x_warning.h>
43 #include <mutex> // unique_lock
50 /// condition_variable
51 class condition_variable
55 #if __GTHREAD_HAS_COND
56 typedef __gthread_cond_t native_handle_type;
58 typedef int native_handle_type;
62 ~condition_variable();
71 wait(unique_lock<mutex>& __lock);
73 template<typename _Predicate>
75 wait(unique_lock<mutex>& __lock, _Predicate __p)
81 template<typename _Duration>
83 timed_wait(unique_lock<mutex>& __lock, const _Duration& __rtime);
86 timed_wait(unique_lock<mutex>& __lock, const system_time& __atime);
88 template<typename _Predicate>
90 timed_wait(unique_lock<mutex>& __lock, const system_time& __atime,
93 template<typename _Duration, typename _Predicate>
95 timed_wait(unique_lock<mutex>& __lock, const _Duration& __rtime,
99 native_handle() { return _M_cond; }
102 native_handle_type _M_cond;
103 condition_variable(const condition_variable&);
104 condition_variable& operator=(const condition_variable&);
107 /// condition_variable_any
108 // Like above, only mutex may not have try_lock.
109 class condition_variable_any
112 #if __GTHREAD_HAS_COND
113 typedef __gthread_cond_t native_handle_type;
115 typedef int native_handle_type;
118 condition_variable_any();
119 ~condition_variable_any();
127 template<typename _Lock>
131 template<typename _Lock, typename _Predicate>
133 wait(_Lock& __lock, _Predicate __p);
135 template<typename _Lock>
137 timed_wait(_Lock& __lock, const system_time& __atime);
139 template<typename _Lock, typename _Duration>
141 timed_wait(_Lock& __lock, const _Duration& __rtime);
143 template<typename _Lock, typename _Predicate>
145 timed_wait(_Lock& __lock, const system_time& __atime, _Predicate __p);
147 template<typename _Lock, typename _Duration, typename _Predicate>
149 timed_wait(_Lock& __lock, const _Duration& __rtime, _Predicate __p);
152 native_handle() { return _M_cond; }
155 native_handle_type _M_cond;
156 condition_variable_any(const condition_variable_any&);
157 condition_variable_any& operator=(const condition_variable_any&);
162 #endif // __GXX_EXPERIMENTAL_CXX0X__
164 #endif // _GLIBCXX_CONDITION_VARIABLE