|
The Pedigree Project 0.1
|
#include <TimerHandlerRegistry.h>
Collaboration diagram for TimerHandlerRegistry:Classes | |
| struct | ActiveDispatch |
| struct | DispatchCleanup |
| struct | HandlerSlot |
Public Member Functions | |
| bool | registerHandler (TimerHandler *handler) |
| bool | armHandler (TimerHandler *handler, uint64_t deadline, uint64_t now) |
| uint64_t | nextDeadline () const |
| bool | unregisterHandler (TimerHandler *handler) |
| bool | dispatch (uint64_t delta, TimerHandler *onlyHandler=nullptr) |
| bool | dispatchDue (uint64_t now) |
| void | reset () |
Private Types | |
| enum class | SlotMode : size_t { Empty = 0 , Enabled , Draining , Deferred , Retiring } |
Private Member Functions | |
| bool | retireSlot (HandlerSlot &slot, size_t expectedPublication, TimerHandler *expectedHandler) |
| bool | publishDispatch (DispatchCleanup &cleanup) |
| bool | unpublishDispatch (DispatchCleanup &cleanup, bool required) |
| bool | hasActiveDispatch (HandlerSlot &slot) const |
| bool | findCurrentDispatch (void *owner, HandlerSlot *target, bool &callbackContext) const |
| bool | dispatchSelected (uint64_t delta, TimerHandler *onlyHandler, bool dueOnly, uint64_t now) |
Static Private Member Functions | |
| static size_t | makePublication (size_t generation, SlotMode mode, bool selfRemoval=false, bool synchronousDrain=false) |
| static size_t | generationOf (size_t publication) |
| static SlotMode | modeOf (size_t publication) |
| static bool | selfRemovalOf (size_t publication) |
| static bool | synchronousDrainOf (size_t publication) |
| static void | abandonDispatch (void *context) |
| static void * | currentDispatchOwner () |
Private Attributes | |
| HandlerSlot | m_Handlers [MaxHandlerSlots] |
| ActiveDispatch | m_ActiveDispatches [MaxActiveDispatches] |
| WaitQueue | m_DispatchWaiters |
| Spinlock | m_HandlerLock |
Static Private Attributes | |
| static constexpr size_t | MaxHandlerSlots = 32 |
| static constexpr size_t | MaxActiveDispatches = 64 |
| static constexpr uint64_t | NoDeadline = ~static_cast<uint64_t>(0) |
| static constexpr size_t | ModeBits = 3 |
| static constexpr size_t | ModeMask = (1 << ModeBits) - 1 |
| static constexpr size_t | SelfRemovalBit = 1 << ModeBits |
| static constexpr size_t | SynchronousDrainBit = 1 << (ModeBits + 1) |
| static constexpr size_t | GenerationShift = ModeBits + 2 |
Allocation-free timer callback registry with synchronous removal.
Dispatch pins atomically published slots without taking the writer lock. Removal closes admission before draining callbacks which committed a pin.
Definition at line 26 of file TimerHandlerRegistry.h.
|
strongprivate |
Definition at line 79 of file TimerHandlerRegistry.h.
| TimerHandlerRegistry::TimerHandlerRegistry | ( | ) |
Definition at line 18 of file TimerHandlerRegistry.cc.
|
staticprivate |
Definition at line 184 of file TimerHandlerRegistry.cc.
| bool TimerHandlerRegistry::armHandler | ( | TimerHandler * | handler, |
| uint64_t | deadline, | ||
| uint64_t | now | ||
| ) |
Arms one callback at an absolute monotonic deadline; zero disarms it.
Definition at line 298 of file TimerHandlerRegistry.cc.
Referenced by Rtc::armHandler().
Here is the caller graph for this function:
|
staticprivate |
Definition at line 234 of file TimerHandlerRegistry.cc.
| bool TimerHandlerRegistry::dispatch | ( | uint64_t | delta, |
| TimerHandler * | onlyHandler = nullptr |
||
| ) |
Calls each handler admitted by the current publication.
Definition at line 519 of file TimerHandlerRegistry.cc.
Referenced by Rtc::processElapsedTime(), and HostedTimer::processTimerBatch().
Here is the caller graph for this function:| bool TimerHandlerRegistry::dispatchDue | ( | uint64_t | now | ) |
Calls each due handler once, with elapsed time since its prior callback.
Definition at line 523 of file TimerHandlerRegistry.cc.
|
private |
Definition at line 527 of file TimerHandlerRegistry.cc.
|
private |
Definition at line 207 of file TimerHandlerRegistry.cc.
|
staticprivate |
Definition at line 39 of file TimerHandlerRegistry.cc.
|
private |
Definition at line 189 of file TimerHandlerRegistry.cc.
|
staticprivate |
Definition at line 33 of file TimerHandlerRegistry.cc.
|
staticprivate |
Definition at line 43 of file TimerHandlerRegistry.cc.
| uint64_t TimerHandlerRegistry::nextDeadline | ( | ) | const |
Returns the earliest armed deadline, or Time::Infinity if none exists.
Definition at line 331 of file TimerHandlerRegistry.cc.
|
private |
Definition at line 74 of file TimerHandlerRegistry.cc.
| bool TimerHandlerRegistry::registerHandler | ( | TimerHandler * | handler | ) |
Definition at line 240 of file TimerHandlerRegistry.cc.
| void TimerHandlerRegistry::reset | ( | ) |
Clears quiescent registry state during timer lifecycle transitions.
Definition at line 625 of file TimerHandlerRegistry.cc.
Referenced by HostedTimer::initialise1(), Rtc::initialise1(), HostedTimer::uninitialise(), and Rtc::uninitialise().
Here is the caller graph for this function:
|
private |
Definition at line 55 of file TimerHandlerRegistry.cc.
|
staticprivate |
Definition at line 47 of file TimerHandlerRegistry.cc.
|
staticprivate |
Definition at line 51 of file TimerHandlerRegistry.cc.
|
private |
Definition at line 107 of file TimerHandlerRegistry.cc.
| bool TimerHandlerRegistry::unregisterHandler | ( | TimerHandler * | handler | ) |
Stops future callbacks and drains callbacks already in progress.
Self-removal is deferred until the callback returns and reports false, preserving Timer's synchronous boolean contract. Other atomic callers report false instead of waiting for an in-flight callback. A synchronous caller must not retain a resource which the active handler needs to finish.
Definition at line 348 of file TimerHandlerRegistry.cc.
References Spinlock::acquire(), ProcessorBase::getInterrupts(), ProcessorBase::information(), ProcessorBase::pause(), and Spinlock::release().
|
staticconstexprprivate |
Definition at line 91 of file TimerHandlerRegistry.h.
|
private |
Definition at line 149 of file TimerHandlerRegistry.h.
|
private |
Definition at line 150 of file TimerHandlerRegistry.h.
|
private |
Definition at line 151 of file TimerHandlerRegistry.h.
|
private |
Definition at line 148 of file TimerHandlerRegistry.h.
|
staticconstexprprivate |
Definition at line 76 of file TimerHandlerRegistry.h.
|
staticconstexprprivate |
Definition at line 75 of file TimerHandlerRegistry.h.
|
staticconstexprprivate |
Definition at line 87 of file TimerHandlerRegistry.h.
|
staticconstexprprivate |
Definition at line 88 of file TimerHandlerRegistry.h.
|
staticconstexprprivate |
Definition at line 77 of file TimerHandlerRegistry.h.
|
staticconstexprprivate |
Definition at line 89 of file TimerHandlerRegistry.h.
|
staticconstexprprivate |
Definition at line 90 of file TimerHandlerRegistry.h.