Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_thread / public / pw_thread / sleep.h
1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 #pragma once
15
16 #include "pw_chrono/system_clock.h"
17 #include "pw_preprocessor/util.h"
18
19 #ifdef __cplusplus
20
21 namespace pw::this_thread {
22
23 // Blocks the execution of the current thread for at least the specified
24 // duration. This function may block for longer due to scheduling or resource
25 // contention delays.
26 //
27 // A sleep duration of 0 will at minimum yield, meaning it will provide a hint
28 // to the implementation to reschedule the execution of threads, allowing other
29 // threads to run.
30 //
31 // This can only be called from a thread, meaning the scheduler is running.
32 void sleep_for(chrono::SystemClock::duration for_at_least);
33
34 // Blocks the execution of the current thread until at least the specified
35 // deadline. This function may block for longer due to scheduling or resource
36 // contention delays.
37 //
38 // A sleep deadline in the past up to the current time will at minimum yield
39 // meaning it will provide a hint to the implementation to reschedule the
40 // execution of threads, allowing other threads to run.
41 //
42 // This can only be called from a thread, meaning the scheduler is running.
43 void sleep_until(chrono::SystemClock::time_point until_at_least);
44
45 }  // namespace pw::this_thread
46
47 // The backend can opt to include inlined implementations.
48 #if __has_include("pw_thread_backend/sleep_inline.h")
49 #include "pw_thread_backend/sleep_inline.h"
50 #endif  // __has_include("pw_thread_backend/sleep_inline.h")
51
52 #endif  // __cplusplus
53
54 PW_EXTERN_C_START
55
56 void pw_this_thread_SleepFor(pw_chrono_SystemClock_Duration for_at_least);
57 void pw_this_thread_SleepUntil(pw_chrono_SystemClock_TimePoint until_at_least);
58
59 PW_EXTERN_C_END