class Timer

Defined at line 33 of file ../../zircon/kernel/include/kernel/timer.h

Timers may be removed from an arbitrary TimerQueue, so their list

node requires the AllowRemoveFromContainer option.

Public Methods

Timer & operator= (Timer & )

Defined at line 41 of file ../../src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/timer.h

void Timer (zx_clock_t clock_id)

Timers need a constexpr constructor, as it is valid to construct them in static storage.

TODO(https://fxbug.dev/328306129): The default value for the clock_id parameter should be

removed, thus forcing users of the Timer class to explicitly declare the clock they wish

to use.

Defined at line 41 of file ../../zircon/kernel/include/kernel/timer.h

void Timer (const Timer & )

Timers are not moved or copied.

Defined at line 47 of file ../../zircon/kernel/include/kernel/timer.h

void Timer (Timer && )

Defined at line 48 of file ../../zircon/kernel/include/kernel/timer.h

Timer & operator= (const Timer & )

Defined at line 49 of file ../../zircon/kernel/include/kernel/timer.h

Timer & operator= (Timer && )

Defined at line 50 of file ../../zircon/kernel/include/kernel/timer.h

void Timer (async_dispatcher_t * dispatcher, std::function<void ()> && callback, Type type)

Construct a timer that will run on |dispatcher| and call |callback| whenever the timer is

triggered. If |type| is Periodic the timer will restart itself after calling |callback|. To

prevent this, call Start with a duration of zero. This can be done inside |callback| to prevent

further timer callbacks. Caller must ensure that |dispatcher| remains running for the lifetime

of the Timer object or until Stop has been called on the timer.

Defined at line 58 of file ../../src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/timer.cc

void SetOneshot (zx_time_t deadline, Callback callback, void * arg)

Equivalent to Set with no slack

The deadline parameter should be interpreted differently depending on the clock_id_ field.

If clock_id_ is set to ZX_CLOCK_MONOTONIC, deadline is a zx_instant_mono_t.

If clock_id_ is set to ZX_CLOCK_BOOT, deadline is a zx_instant_boot_t.

Defined at line 77 of file ../../zircon/kernel/include/kernel/timer.h

zx_duration_t slack_for_test ()

Private accessors for timer tests.

Defined at line 89 of file ../../zircon/kernel/include/kernel/timer.h

zx_time_t scheduled_time_for_test (zx_clock_t expected_clock_id)

This function returns a zx_instant_mono_t if the expected_clock_id is ZX_CLOCK_MONOTONIC and a

zx_instant_boot_t if the expected_clock_id is ZX_CLOCK_BOOT.

Defined at line 93 of file ../../zircon/kernel/include/kernel/timer.h

void ~Timer ()

Destroying the timer will synchronously Stop the timer before completing destruction.

Defined at line 315 of file ../../zircon/kernel/kernel/timer.cc

zx_status_t Start (zx_duration_t interval)

Start the timer with |interval| amount of time before the timer triggers. The same interval is

used when restarting the timer if it is periodic. Calling Start with an |interval| of zero on a

periodic timer will allow the timer to trigger at its next scheduled time but it will not

restart after that. Calling Start with an |interval| of zero on a one-shot timer has no effect.

Calling Start with |interval| greater than zero will adjust the timer interval to the new value

AND postpone any upcoming trigger to not be called until |interval| amount of time has passed.

For periodic timers this will also adjust the interval of all future timer triggers. This can

safely be done from the timer callback.

Returns |ZX_OK| on success.

Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.

Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.

Defined at line 65 of file ../../src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/timer.cc

void Stop ()

Stop a running timer synchronously, blocking until the stop is complete. When Stop returns the

callback provided in the constructor is guaranteed to not run again until Start is called. If

the callback is currently running it will run to completion before Stop returns.

Defined at line 93 of file ../../src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/timer.cc

bool Stopped ()

Defined at line 110 of file ../../src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/timer.cc

void Set (const Deadline & deadline, Callback callback, void * arg)

Set up a timer that executes once

This function specifies a callback function to be run after a specified

deadline passes. The function will be called one time.

deadline: specifies when the timer should be executed

callback: the function to call when the timer expires

arg: the argument to pass to the callback

The timer function is declared as:

void callback(Timer *, zx_time_t now, void *arg) { ... }

Defined at line 322 of file ../../zircon/kernel/kernel/timer.cc

bool Cancel ()

Cancel a pending timer

Returns true if the timer was canceled before it was

scheduled in a cpu and false otherwise or if the timer

was not scheduled at all.

Defined at line 389 of file ../../zircon/kernel/kernel/timer.cc

zx_status_t TrylockOrCancel (MonitoredSpinLock * lock)

Special helper routine to simultaneously try to acquire a spinlock and

check for timer cancel, which is needed in a few special cases. Returns

ZX_OK if spinlock was acquired, ZX_ERR_TIMED_OUT if timer was canceled.

Defined at line 555 of file ../../zircon/kernel/kernel/timer.cc

zx_status_t TrylockOrCancel (ChainLock & lock)

Defined at line 571 of file ../../zircon/kernel/kernel/timer.cc

Enumerations

enum Type
Name Value
OneShot 0
Periodic 1

A OneShot timer will only fire once for each call to Start. A Periodic timer will fire

regularly at the interval specified in the Start call.

Defined at line 29 of file ../../src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/timer.h

Records

Friends

class TimerQueue