atMETEO
An ATmega based weather station
Files | Classes

Utilities for ensuring atomic / non atomic execution of code blocks. More...

Collaboration diagram for Atomic execution:

Files

file  atomic.h
 Utilities for ensuring atomic / non atomic execution of code blocks.
 

Classes

class  Avr::AtomicGuard< TAtomicMode >
 RAII-style wrapper to disable interrupts for the duration of a scoped block. More...
 
class  Avr::AtomicForceOn
 Configuration parameter for AtomicGuard that unconditionally enables interrupts on exit. More...
 
class  Avr::AtomicRestoreState
 Configuration parameter for AtomicGuard that saves the global interrupt state and restores it on exit. More...
 
class  Avr::NonAtomicGuard< TNonAtomicMode >
 RAII-style wrapper to enable interrupts for the duration of a scoped block. More...
 
class  Avr::NonAtomicForceOff
 Configuration parameter for NonAtomicGuard that unconditionally disables interrupts on exit. More...
 
class  Avr::NonAtomicRestoreState
 Configuration parameter for NonAtomicGuard that saves the global interrupt state and restores it on exit. More...
 

Detailed Description

Utilities for ensuring atomic / non atomic execution of code blocks.

This module contains RAII-style utilities that ensure atomic / non atomic execution of scoped blocks by controlling the global interrupt state (in the SREG register).

Usage:

int main() {
// ...
{
// Interrupts are guaranteed to be disabled
}
// ...
}
See also
http://www.nongnu.org/avr-libc/user-manual/group__util__atomic.html

Class Documentation

◆ Avr::AtomicGuard

class Avr::AtomicGuard

template<class TAtomicMode>
class Avr::AtomicGuard< TAtomicMode >

RAII-style wrapper to disable interrupts for the duration of a scoped block.

Template Parameters
TAtomicModeControls if interrupts should be globally enabled (AtomicForceOn) or if the global interrupt state should be restored (AtomicRestoreState) when leaving the scoped block.

◆ Avr::AtomicForceOn

class Avr::AtomicForceOn

Configuration parameter for AtomicGuard that unconditionally enables interrupts on exit.

An AtomicGuard with AtomicForceOn avoids saving the SREG status and hence saves flash space. A safer alternative is AtomicRestoreState which will save and restore the interrupt state.

◆ Avr::AtomicRestoreState

class Avr::AtomicRestoreState

Configuration parameter for AtomicGuard that saves the global interrupt state and restores it on exit.

◆ Avr::NonAtomicGuard

class Avr::NonAtomicGuard

template<class TNonAtomicMode>
class Avr::NonAtomicGuard< TNonAtomicMode >

RAII-style wrapper to enable interrupts for the duration of a scoped block.

NonAtomicGuard is especially useful within an block where interrupts are globally disabled using AtomicGuard.

Template Parameters
TNonAtomicModeControls if interrupts should be globally disabled (NonAtomicForceOff) or if the global interrupt state should be restored (NonAtomicRestoreState) when leaving the scoped block.

◆ Avr::NonAtomicForceOff

class Avr::NonAtomicForceOff

Configuration parameter for NonAtomicGuard that unconditionally disables interrupts on exit.

A NonAtomicGuard with NonAtomicForceOff avoids saving the SREG status and hence saves flash space. A safer alternative is NonAtomicRestoreState which will save and restore the interrupt state.

◆ Avr::NonAtomicRestoreState

class Avr::NonAtomicRestoreState

Configuration parameter for NonAtomicGuard that saves the global interrupt state and restores it on exit.