A namespace for functions applying to the current thread.
More...
|
| thread::id | get_id () noexcept |
| | Return the id of the current running thread.
|
| |
| template<typename Clock_T = os::estd::chrono::systick_clock, typename Rep_T , typename Period_T > |
| constexpr void | sleep_for (const std::chrono::duration< Rep_T, Period_T > &rel_time) |
| | Sleep for a given duration.
|
| |
| template<typename Clock_T , typename Duration_T > |
| void | sleep_until (const std::chrono::time_point< Clock_T, Duration_T > &abs_time) |
| | Sleep until a given time point.
|
| |
| template<typename Duration_T > |
| void | sleep_until (const std::chrono::time_point< os::estd::chrono::realtime_clock, Duration_T > &abs_time) |
| |
| template<typename Duration_T > |
| void | sleep_until (const std::chrono::time_point< os::estd::chrono::systick_clock, Duration_T > &abs_time) |
| |
| void | yield () noexcept |
| | Yield the CPU to the next ready thread.
|
| |
◆ get_id()
Definition at line 405 of file thread_internal.h.
406 {
408 }
thread & thread(void)
Get the current running thread.
◆ sleep_for()
template<typename Clock_T = os::estd::chrono::systick_clock, typename Rep_T , typename Period_T >
| constexpr void this_thread::sleep_for |
( |
const std::chrono::duration< Rep_T, Period_T > & |
rel_time | ) |
|
|
constexpr |
- Parameters
-
| [in] | rel_time | sleep duration. |
extra Clock_T is an extension to the standard
Definition at line 467 of file thread_internal.h.
468 {
469 using namespace std::chrono;
470
471 using clock = Clock_T;
472 using sleep_rep = typename clock::sleep_rep;
473
474 if (rel_time > duration<Rep_T, Period_T>::zero ())
475 {
476 sleep_rep d = static_cast<sleep_rep> (
477 os::estd::chrono::ceil<typename clock::duration> (rel_time)
478 .count ());
479
480 clock::sleep_for (d);
481 }
482 }
◆ sleep_until() [1/3]
template<typename Clock_T , typename Duration_T >
| void this_thread::sleep_until |
( |
const std::chrono::time_point< Clock_T, Duration_T > & |
abs_time | ) |
|
- Parameters
-
| [in] | abs_time | Absolute time point. |
Definition at line 488 of file thread_internal.h.
489 {
490 using clock = Clock_T;
491
492#pragma GCC diagnostic push
493#if defined(__clang__)
494#elif defined(__GNUC__)
495#pragma GCC diagnostic ignored "-Waggregate-return"
496#endif
497
498 auto now = clock::now ();
499
500 while (now < abs_time)
501 {
503 now = clock::now ();
504 }
505
506#pragma GCC diagnostic pop
507 }
constexpr void sleep_for(const std::chrono::duration< Rep_T, Period_T > &rel_time)
Sleep for a given duration.
◆ sleep_until() [2/3]
template<typename Duration_T >
Definition at line 511 of file thread_internal.h.
513 {
515
516#pragma GCC diagnostic push
517#if defined(__clang__)
518#elif defined(__GNUC__)
519#pragma GCC diagnostic ignored "-Waggregate-return"
520#endif
521
522 auto now = clock::now ();
523 while (now < abs_time)
524 {
525 typename clock::sleep_rep d
526 = (os::estd::chrono::ceil<typename clock::sleep_duration> (abs_time
527 - now))
528 .count ();
529 clock::sleep_for (d);
530 now = clock::now ();
531 }
532
533#pragma GCC diagnostic pop
534 }
◆ sleep_until() [3/3]
template<typename Duration_T >
Definition at line 538 of file thread_internal.h.
540 {
542
543#pragma GCC diagnostic push
544#if defined(__clang__)
545#elif defined(__GNUC__)
546#pragma GCC diagnostic ignored "-Waggregate-return"
547#endif
548
549 auto now = clock::now ();
550 while (now < abs_time)
551 {
552 typename clock::sleep_rep d
553 = (os::estd::chrono::ceil<typename clock::sleep_duration> (abs_time
554 - now))
555 .count ();
556 clock::sleep_for (d);
557 now = clock::now ();
558 }
559
560#pragma GCC diagnostic pop
561 }
◆ yield()
| void this_thread::yield |
( |
void |
| ) |
|
|
inlinenoexcept |