nn::os::Alarm

nn::os::Alarm Class

Header file: nn/os.h

Syntax

class Alarm :
    private nn::os::QueueableWaitTask,
    private nn::util::NonCopyable< Alarm >

Description

Class for handling alarms.

Alarms use the timer functionality of the OS to call a handler after the specified time has elapsed. When the handler is called, its first argument is the argument that was used when the alarm was set, and its second argument is false.

(This content of this paragraph may be changed in the future. ) To use this class you must first call nn::os::InitializeAlarmSystem. Alarm handlers are run in certain specific threads, and in the current implementation the number of these threads is limited to two. As a result, the alarm system will become unstable if you register many handlers that take a long time to complete (for example, those that perform thread blocking).

There are two types of alarms: one-shot alarms and periodic alarms.

One-shot alarms are set using SetOneShot and cause a handler to be called after a fixed period of time. After calling either of these functions once, it is not possible to call SetOneShot or SetPeriodic again until the handler starts. These setter functions can be called again within the handler.

Periodic alarms are set using SetPeriodic and cause a handler to be called periodically thereafter. It is not possible to call either SetOneShot or SetPeriodic again while a periodic alarm is active.

You can cancel an alarm before the handler has run by calling Cancel. If the handler has already started, the handler will not be cancelled even if you call Cancel. If Cancel is called while an alarm is set (before a periodic alarm or one-shot alarm calls the handler), the alarm handler is called with its second argument set to true.

Member Functions

Alarm Constructs an object. No initialization is performed. Before using the object, you must initialize it explicitly by calling Initialize.
V ~Alarm Destroys an object. Calls Finalize. This function cannot be called when an alarm is currently set.
TryInitialize Tries to initialize an alarm object.
Initialize Initializes an alarm object.
Finalize Finalizes an alarm. This function cannot be called when an alarm is currently set.
SetOneShot Sets a one-shot alarm. Calls the handler only once after the specified time has elapsed.
SetPeriodic Sets a periodic alarm. Calls the handler once after the initial duration has elapsed and thereafter continues calling it at the specified interval.
Cancel Cancels an alarm that has been set.
CanSet Determines whether the current state allows alarms to be set.

Class Hierarchy

nn::util::NonCopyable
  nn::fnd::IntrusiveQueue
    nn::os::QueueableTask
      nn::os::QueueableWaitTask
        nn::os::Alarm

Revision History

2010/01/07
Initial version.

CONFIDENTIAL