pebble/io/stores/store_cadence.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * @file store_cadence.c | ||
| 3 | * @brief Holds the list of work the stores want run on the face's cadence. | ||
| 4 | * | ||
| 5 | * @ingroup lib_stores | ||
| 6 | */ | ||
| 7 | #include "io/stores/store_cadence.h" | ||
| 8 | |||
| 9 | #include "io/callback_list.h" | ||
| 10 | |||
| 11 | static CallbackListFn s_entries[STORE_CADENCE_MAX]; ///< The registered work, in the order it was registered | ||
| 12 | static CallbackList s_list = {s_entries, STORE_CADENCE_MAX, 0}; ///< The list over that storage | ||
| 13 | |||
| 14 | 14 | void store_cadence_register(void (*cb)(void)) | |
| 15 | { | ||
| 16 | // a full list means a store quietly stops getting its cadence, so the size is set by how many | ||
| 17 | // stores there are rather than by guesswork. a registration that does not fit is logged as an | ||
| 18 | // error and dropped | ||
| 19 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 2 taken 11 times.
|
14 | if (!callback_list_add(&s_list, cb)) |
| 20 | { | ||
| 21 | 3 | APP_LOG(APP_LOG_LEVEL_ERROR, "store cadence full, dropping a registration"); | |
| 22 | } | ||
| 23 | 14 | } | |
| 24 | |||
| 25 | 8 | void store_cadence_fire(void) | |
| 26 | { | ||
| 27 | 8 | callback_list_fire(&s_list); | |
| 28 | 8 | } | |
| 29 |