title: tk::PreemptGuard summary: プリエンプション禁止をスコープ単位で安全に管理する RAII クラス
プリエンプション禁止をスコープ単位で安全に管理する RAII クラス More...
#include <kernel.hpp>
| Name | |
|---|---|
| PreemptGuard() | |
| ~PreemptGuard() | |
| PreemptGuard(const PreemptGuard & ) =delete | |
| PreemptGuard & | operator=(const PreemptGuard & ) =delete |
class tk::PreemptGuard;
プリエンプション禁止をスコープ単位で安全に管理する RAII クラス
生成時に自動で [tk::preempt_disable()](Namespaces/namespacetk.md#function-preempt-disable) を呼び、スコープを抜けた際に自動で [tk::preempt_enable()](Namespaces/namespacetk.md#function-preempt-enable) を呼びます。
{
tk::PreemptGuard guard;
// この区間はタスクスイッチが発生しない (I2C/SPI通信などに最適)
i2c_write_blocking(...);
} // 自動でタスクスイッチが再開
inline PreemptGuard()
inline ~PreemptGuard()
PreemptGuard(
const PreemptGuard &
) =delete
PreemptGuard & operator=(
const PreemptGuard &
) =delete
Updated on 2026-10-02 at 14:01:32 +0900