9dac4305979232b04b1551df572097408ec68f57
[platform/upstream/tbb.git] / include / tbb / compat / thread
1 /*
2     Copyright (c) 2005-2019 Intel Corporation
3
4     Licensed under the Apache License, Version 2.0 (the "License");
5     you may not use this file except in compliance with the License.
6     You may obtain a copy of the License at
7
8         http://www.apache.org/licenses/LICENSE-2.0
9
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15 */
16
17 #ifndef __TBB_thread_H
18 #define __TBB_thread_H
19
20 #include "../tbb_config.h"
21
22 #if TBB_IMPLEMENT_CPP0X
23
24 #include "../tbb_thread.h"
25
26 namespace std {
27
28 typedef tbb::tbb_thread thread;
29
30 namespace this_thread {
31     using tbb::this_tbb_thread::get_id;
32     using tbb::this_tbb_thread::yield;
33
34     inline void sleep_for(const tbb::tick_count::interval_t& rel_time) {
35         tbb::internal::thread_sleep_v3( rel_time );
36     }
37 }
38
39 } // namespace std
40
41 #else /* TBB_IMPLEMENT_CPP0X */
42
43 #define __TBB_COMPAT_THREAD_RECURSION_PROTECTOR 1
44 #include <thread>
45 #undef __TBB_COMPAT_THREAD_RECURSION_PROTECTOR
46
47 #endif /* TBB_IMPLEMENT_CPP0X */
48
49 #else /* __TBB_thread_H */
50
51 #if __TBB_COMPAT_THREAD_RECURSION_PROTECTOR
52 #error The tbb/compat/thread header attempts to include itself. \
53        Please make sure that {TBBROOT}/include/tbb/compat is NOT in include paths.
54 #endif
55
56 #endif /* __TBB_thread_H */