Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions | Static Public Member Functions
CriticalSectionLock Class Reference

RAII object for disabling, then restoring, interrupt state Usage: More...

#include <CriticalSectionLock.h>

Public Member Functions

void lock ()
 Mark the start of a critical section. More...
 
void unlock ()
 Mark the end of a critical section. More...
 

Static Public Member Functions

static void enable ()
 Mark the start of a critical section. More...
 
static void disable ()
 Mark the end of a critical section. More...
 

Detailed Description

RAII object for disabling, then restoring, interrupt state Usage:

// RAII style usage
unsigned int atomic_counter_increment(unsigned int &counter) {
CriticalSectionLock lock;
// Code in this block will run with interrupts disabled
// Interrupts will be restored to their previous state automatically
// at the end of function scope
return ++counter;
}
// free locking usage
unsigned int atomic_counter_decrement(unsigned int &counter) {
// Code in this block will run with interrupts disabled
counter--;
CriticalSectionLock::disable(); // need explicitly to disable critical section lock
// interrupts will be restored to their previous state here
return counter;
}

Definition at line 56 of file CriticalSectionLock.h.

Member Function Documentation

static void disable ( )
static

Mark the end of a critical section.

static void enable ( )
static

Mark the start of a critical section.

void lock ( )

Mark the start of a critical section.

Deprecated:
This function is inconsistent with RAII and is being removed in the future.

Replaced by static function CriticalSectionLock::enable.

void unlock ( )

Mark the end of a critical section.

Deprecated:
This function is inconsistent with RAII and is being removed in the future.

Replaced by static function CriticalSectionLock::enable.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.