MySQL 9.1.0
Source Code Documentation
ut::Todo_counter Class Reference

A counter which tracks number of things left to do, which can be incremented or decremented, and lets one await the value drop to zero. More...

#include <ut0todo_counter.h>

Public Member Functions

 Todo_counter ()
 Initializes the counter to 0. More...
 
void increment ()
 Increments the value of the counter. More...
 
void decrement ()
 Decrements the value of the counter. More...
 
void await_zero ()
 Returns when the value is zero. More...
 
size_t value ()
 Returns current value of the counter. More...
 

Private Attributes

size_t m_todos {0}
 
Os_event_t m_is_zero {}
 

Detailed Description

A counter which tracks number of things left to do, which can be incremented or decremented, and lets one await the value drop to zero.

Enforcing a total order on calls to increment(), decrement() and value() is a responsibility of a user of this class. With above assumption the await_zero() can be called safely at any moment, as increment() and decrement() take care of resetting and setting the awaited event object properly.

Constructor & Destructor Documentation

◆ Todo_counter()

ut::Todo_counter::Todo_counter ( )
inline

Initializes the counter to 0.

Member Function Documentation

◆ await_zero()

void ut::Todo_counter::await_zero ( )
inline

Returns when the value is zero.

◆ decrement()

void ut::Todo_counter::decrement ( )
inline

Decrements the value of the counter.

◆ increment()

void ut::Todo_counter::increment ( )
inline

Increments the value of the counter.

◆ value()

size_t ut::Todo_counter::value ( )
inline

Returns current value of the counter.

Member Data Documentation

◆ m_is_zero

Os_event_t ut::Todo_counter::m_is_zero {}
private

◆ m_todos

size_t ut::Todo_counter::m_todos {0}
private

The documentation for this class was generated from the following file: