Mbed OS Reference
Loading...
Searching...
No Matches
HighResClock Class Reference

A C++11 Clock representing the HAL us_ticker. More...

#include <HighResClock.h>

Static Public Member Functions

static time_point now ()
 Read the current time. More...
 
static void lock ()
 Lock the clock to ensure it stays running. More...
 
static void unlock ()
 Unlock the clock, allowing it to stop during power saving. More...
 

Detailed Description

A C++11 Clock representing the HAL us_ticker.

The high resolution clock will pause whenever deep sleep is entered.

Lock and unlock methods are provided to control deep sleep to keep the clock running. LowPowerClock provides the same methods as dummies to support generic code that works with either clock.

Locks and unlocks are passed to the deep sleep manager, so are reference counted.

The lock and unlock methods mean this is a C++11 BasicLockable class, so scoped_lock<HighResClock> or unique_lock<HighResClock> could be used to manage ownership and guarantee balanced unlocking.

Note
To avoid the need to worry about locking, consider using the Timer, Ticker or Timeout classes, which lock automatically and only whenever they are active

Definition at line 49 of file HighResClock.h.

Member Function Documentation

◆ now()

static time_point now ( )
static

Read the current time.

Definition at line 59 of file HighResClock.h.

◆ lock()

static void lock ( )
static

Lock the clock to ensure it stays running.

Definition at line 65 of file HighResClock.h.

◆ unlock()

static void unlock ( )
static

Unlock the clock, allowing it to stop during power saving.

Definition at line 71 of file HighResClock.h.