Changed notification call function name from 'invoke' to 'on_time_to_next_notification'.

Changed `active_notify_time_to_next` to 'notify_time_to_next'.
Updated documentation.
This commit is contained in:
John Wellbelove 2026-11-01 11:50:28 +00:00
parent bcc69cf16d
commit 357d4765da
6 changed files with 24 additions and 44 deletions

View File

@ -26,63 +26,45 @@ The `etl::intrusive_timer` is a replacement for all legacy timers within the ETL
- **Dynamic Scheduling**
Features a configurable notification hook that fires whenever the next due timer changes, yielding the precise 'time-to-next' interval to user code.
## timer_lock_policy
## etl::timer::lock_policy
```cpp
class timer_lock_policy
class lock_policy
```
**Description**
Interface for a timer lock policy.
Derive from this to implement your own lock policy.
Declares the following pure virtual functions.
See [lock_policy]({{< relref "timer-lock-policy.md#lock_policy" >}})
---
`virtual void lock() ETL_NOEXCEPT`
Locks access.
---
`virtual void unlock() ETL_NOEXCEPT`
Unlocks access.
---
`virtual bool is_locked() ETL_NOEXCEPT`
Returns `true` if access is locked.
## timer_no_lock_policy
## etl::timer::no_lock_policy
```cpp
class timer_no_lock_policy : public timer_lock_policy
class no_lock_policy : public timer_lock_policy
```
**Description**
A predefined lock policy does no locking.
Useful for single threaded code or testing purposes.
## timer_atomic_lock_policy
See [no_lock_policy]({{< relref "timer-lock-policy.md#no_lock_policy" >}})
## etl::timer::atomic_lock_policy
```cpp
class timer_atomic_lock_policy : public timer_lock_policy
class atomic_lock_policy : public timer_lock_policy
```
**Description**
A predefined lock policy that uses an atomic flag.
Only defined if `ETL_HAS_ATOMIC` is `1`.
## timer_time_to_next_notification
See [atomic_lock_policy]({{< relref "timer-lock-policy.md#atomic_lock_policy" >}})
## etl::timer::time_to_next_notification
```cpp
timer_time_to_next_notification
time_to_next_notification
```
**Description**
This is the base class for 'time to next' notifications.
Derive from this to define a custom implementation.
---
```cpp
virtual void invoke(etl::timer::interval::type delta)
```
**Description**
Called to notify user code of the 'time to next' delta for the next due timer.
If not overridden, then does nothing.
See [timer_notification]({{< relref "timer-notification.md" >}})
## intrusive_timer
```cpp

View File

@ -10,17 +10,15 @@ weight: 104
From: `C++03`
{{< /callout >}}
## Description
## time_to_next_notification
```cpp
timer_time_to_next_notification
time_to_next_notification
```
**Description**
This is the base class for 'time to next' notifications.
Derive from this to define a custom implementation.
```cpp
virtual void invoke(etl::timer::interval::type)
virtual void on_time_to_next_notification(etl::timer::interval::type)
```
If not overridden then does nothing.
If not overridden then does nothing.

View File

@ -60,7 +60,7 @@ namespace etl
, register_list()
, active_list()
, expired_list()
, active_notify_time_to_next(&default_notify_time_to_next)
, notify_time_to_next(&default_notify_time_to_next)
, enabled(false)
, timer_count(0U)
{
@ -433,7 +433,7 @@ namespace etl
//*******************************************
void set_next_timer_notification(etl::timer::time_to_next_notification& notification) ETL_NOEXCEPT
{
active_notify_time_to_next = &notification;
notify_time_to_next = &notification;
}
//*******************************************
@ -441,7 +441,7 @@ namespace etl
//*******************************************
void clear_next_timer_notification() ETL_NOEXCEPT
{
active_notify_time_to_next = &default_notify_time_to_next;
notify_time_to_next = &default_notify_time_to_next;
}
//*******************************************
@ -473,7 +473,7 @@ namespace etl
if (notify_)
{
// The next timer has changed, so notify the user.
active_notify_time_to_next->invoke(timer_->get_delta());
notify_time_to_next->on_time_to_next_notification(timer_->get_delta());
}
}
@ -530,7 +530,7 @@ namespace etl
etl::private_timer::expired_list expired_list;
etl::timer::time_to_next_notification default_notify_time_to_next;
etl::timer::time_to_next_notification* active_notify_time_to_next;
etl::timer::time_to_next_notification* notify_time_to_next;
bool enabled;
size_t timer_count;

View File

@ -47,7 +47,7 @@ namespace etl
{
public:
virtual void invoke(etl::timer::interval::type)
virtual void on_time_to_next_notification(etl::timer::interval::type)
{
// Do nothing by default.
}

View File

@ -222,7 +222,7 @@ namespace
{
public:
void invoke(uint32_t delta) override
void on_time_to_next_notification(uint32_t delta) override
{
time_to_next.push_back(delta);
}