class Timer

Defined at line 27 of file ../../src/connectivity/wlan/drivers/lib/timer/cpp/include/wlan/drivers/timer/timer.h

A timer object that allows the user to start both oneshot and periodic timers. Destroying the

timer object will first stop the timer. Note that StartPeriodic, StartOneshot and Stop are

synchronous. Therefore the caller should be careful about holding locks that would prevent a

timer trigger from completing when calling these methods. I.e. if the timer is in the middle of

calling the callback and the callback is blocked on a lock held by the thread calling

StartOneshot, StartPeriodic or Stop then those methods will never return.

Calls to StartPeriodic, StartOneshot and Stop are mutually exclusive with eachother. If multiple

threads call into these methods at the same time they will be processed sequentially and the

order in which they are scheduled will determine the outcome.

Public Methods

void Timer (async_dispatcher_t * dispatcher, FunctionPtr callback, void * context)

Create a timer where `callback` will be called on `dispatcher`. The `context` parameter will

be provided in the call.

Defined at line 12 of file ../../src/connectivity/wlan/drivers/lib/timer/cpp/timer.cc

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

Create a timer where `callback` will be called on `dispatcher`.

Defined at line 15 of file ../../src/connectivity/wlan/drivers/lib/timer/cpp/timer.cc

void ~Timer ()

Defined at line 20 of file ../../src/connectivity/wlan/drivers/lib/timer/cpp/timer.cc

zx_status_t StartPeriodic (zx_duration_mono_t interval)

Start a periodic timer that will trigger at the specified interval. StartPeriodic is threadsafe

and can be called from the callback or elsewhere. Calling StartPeriodic on a running timer is

perfectly fine and will stop the existing timer and start it again with new parameters. If two

threads call StartPeriodic or StartOneshot at the same time they will be sequenced such that it

will appear as if one of them was made before the other. This means they will both succeed but

only the one sequenced last will have its parameters used for the timer. The timer will not

trigger twice. Negative intervals are not supported but a zero interval is OK (but probably not

advisable).

Defined at line 27 of file ../../src/connectivity/wlan/drivers/lib/timer/cpp/timer.cc

zx_status_t StartOneshot (zx_duration_mono_t delay)

Start a oneshot timer that will trigger after the specified delay. StartOneshot is threadsafe

and can be called from the callback or elsewhere. Calling StartOneshot on a running timer is

perfectly fine and will stop the existing timer and start it again with new parameters. If two

threads call StartPeriodic or StartOneshot at the same time they will be sequenced such that it

will appear as if one of them was made before the other. This means they will both succeed but

only the one sequenced last will have its parameters used for the timer. The timer will not

trigger twice. Negative delays are not supported but zero delay is OK.

Defined at line 29 of file ../../src/connectivity/wlan/drivers/lib/timer/cpp/timer.cc

zx_status_t Stop ()

Stop the timer if possible. If the timer has not yet triggered it will be stopped without any

calls to callback. If the timer is in the process of triggering there may still be a call to

callback but after Stop returns no further callbacks will be made. Stop is threadsafe and can

be called from a timer callback or anywhere else.

Defined at line 31 of file ../../src/connectivity/wlan/drivers/lib/timer/cpp/timer.cc

void Timer (const Timer & )

Copying and moving cannot be done safely as the asynchronous tasks rely on the specific pointer

to the timer in question.

Defined at line 41 of file ../../src/connectivity/wlan/drivers/lib/timer/cpp/include/wlan/drivers/timer/timer.h

Timer & operator= (const Timer & )

Defined at line 42 of file ../../src/connectivity/wlan/drivers/lib/timer/cpp/include/wlan/drivers/timer/timer.h