zpp
Zephyr C++20 Framework
sched.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019 Erwin Rol <erwin@erwinrol.com>
3 //
4 // SPDX-License-Identifier: Apache-2.0
5 //
6 
7 #ifndef ZPP_INCLUDE_ZPP_SCHED_HPP
8 #define ZPP_INCLUDE_ZPP_SCHED_HPP
9 
10 #include <zephyr/kernel.h>
11 #include <zephyr/sys/__assert.h>
12 
13 namespace zpp {
14 
18 inline void sched_lock() noexcept
19 {
20  k_sched_lock();
21 }
22 
26 inline void sched_unlock() noexcept
27 {
28  k_sched_unlock();
29 }
30 
35 public:
39  sched_lock_guard() noexcept
40  {
41  sched_lock();
42  }
43 
48  {
49  sched_unlock();
50  }
51 public:
54  sched_lock_guard(sched_lock_guard&&) noexcept = delete;
55  sched_lock_guard& operator=(sched_lock_guard&&) noexcept = delete;
56 };
57 
58 } // namespace zpp
59 
60 #endif // ZPP_INCLUDE_ZPP_SCHED_HPP
Guard to automatically lock/unlock scheduler.
Definition: sched.hpp:34
sched_lock_guard & operator=(const sched_lock_guard &)=delete
sched_lock_guard() noexcept
Default constructor that calls scheck_lock()
Definition: sched.hpp:39
sched_lock_guard(sched_lock_guard &&) noexcept=delete
~sched_lock_guard()
Destructor that calls sched_unlock()
Definition: sched.hpp:47
sched_lock_guard(const sched_lock_guard &)=delete
void sched_unlock() noexcept
Unlock the scheduler.
Definition: sched.hpp:26
void sched_lock() noexcept
Lock the scheduler.
Definition: sched.hpp:18