classtk_1_1_preempt_guard.md 1.9 KB


title: tk::PreemptGuard summary: プリエンプション禁止をスコープ単位で安全に管理する RAII クラス


tk::PreemptGuard

プリエンプション禁止をスコープ単位で安全に管理する RAII クラス More...

#include <kernel.hpp>

Public Functions

Name
PreemptGuard()
~PreemptGuard()
PreemptGuard(const PreemptGuard & ) =delete
PreemptGuard & operator=(const PreemptGuard & ) =delete

Detailed Description

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(...);
} // 自動でタスクスイッチが再開

Public Functions Documentation

function PreemptGuard

inline PreemptGuard()

function ~PreemptGuard

inline ~PreemptGuard()

function PreemptGuard

PreemptGuard(
    const PreemptGuard & 
) =delete

function operator=

PreemptGuard & operator=(
    const PreemptGuard & 
) =delete

Updated on 2026-10-02 at 14:01:32 +0900