Module kernel::time::hrtimer

source ·
Expand description

Intrusive high resolution timers.

Allows running timer callbacks without doing allocations at the time of starting the timer. For now, only one timer per type is allowed.

§Vocabulary

States:

  • Stopped: initialized but not started, or cancelled, or not restarted.
  • Started: initialized and started or restarted.
  • Running: executing the callback.

Operations:

  • Start
  • Cancel
  • Restart

Events:

  • Expire

§State Diagram

                                                  Return NoRestart
                      +---------------------------------------------------------------------+
                      |                                                                     |
                      |                                                                     |
                      |                                                                     |
                      |                                         Return Restart              |
                      |                                      +------------------------+     |
                      |                                      |                        |     |
                      |                                      |                        |     |
                      v                                      v                        |     |
          +-----------------+      Start      +------------------+           +--------+-----+--+
          |                 +---------------->|                  |           |                 |
Init      |                 |                 |                  |  Expire   |                 |
--------->|    Stopped      |                 |      Started     +---------->|     Running     |
          |                 |     Cancel      |                  |           |                 |
          |                 |<----------------+                  |           |                 |
          +-----------------+                 +---------------+--+           +-----------------+
                                                    ^         |
                                                    |         |
                                                    +---------+
                                                     Restart

A timer is initialized in the stopped state. A stopped timer can be started by the start operation, with an expiry time. After the start operation, the timer is in the started state. When the timer expires, the timer enters the running state and the handler is executed. After the handler has returned, the timer may enter the *started or stopped state, depending on the return value of the handler. A timer in the started or running state may be canceled by the cancel operation. A timer that is cancelled enters the stopped state.

A cancel or restart operation on a timer in the running state takes effect after the handler has returned and the timer has transitioned out of the running state.

A restart operation on a timer in the stopped state is equivalent to a start operation.

Structs§

Enums§

Traits§