class AutoPreemptDisabler

Defined at line 41 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h

AutoPreemptDisabler is a RAII helper that automatically manages disabling and

re-enabling preemption. When the object goes out of scope, it automatically

re-enables preemption if it had been previously disabled by the instance.

Example usage:

// Immediately disable preemption, then obtain the list_ lock and append an

// element to the list.

{

AutoPreemptDisabler preempt_disabler;

Guard

<Mutex

> guard{

&lock

_};

list_.push_back(ktl::move(element_uptr));

}

// Reserve the option to disable preemption, but do not do so right now.

{

AutoPreemptDisabler preempt_disabler{AutoPreemptDisabler::Defer};

Guard

<Mutex

> guard{

&lock

_};

// Do some work.

if (predicate()) {

preempt_disabler.Disable();

// Do some more work with preemption disabled.

}

} // lock_ is released first, then (if predicate() was true), preemption is re-enabled.

Public Methods

void AutoPreemptDisabler ()

Defined at line 47 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h

void AutoPreemptDisabler (DeferType )

Defined at line 48 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h

void ~AutoPreemptDisabler ()

Defined at line 50 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h

void AutoPreemptDisabler (const AutoPreemptDisabler & )

Defined at line 52 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h

AutoPreemptDisabler & operator= (const AutoPreemptDisabler & )

Defined at line 53 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h

void AutoPreemptDisabler (AutoPreemptDisabler && )

Defined at line 54 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h

AutoPreemptDisabler & operator= (AutoPreemptDisabler && )

Defined at line 55 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h

void Disable ()

Disables preemption if it was not disabled by this instance already.

Defined at line 58 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h

void Enable ()

Enables preemption if it was previously disabled by this instance.

Defined at line 66 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h

void AssertDisabled ()

Defined at line 73 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h

Enumerations

enum DeferType
Name Value
Defer 0

Tag type to construct the AutoPreemptDisabler without preemption initially

disabled.

Defined at line 45 of file ../../zircon/kernel/include/kernel/auto_preempt_disabler.h