mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-30 21:18:25 +00:00
move timer stuff out of sntp/util
This commit is contained in:
1 parent
3322a119eb
commit
48a6b0d422
10 files changed
+184
-180
No files matched your search
+28
-27
@@ -1807,6 +1807,33 @@ void mg_log_set_fn(mg_pfn_t fn, void *param);
|
||||
|
||||
|
||||
|
||||
// Return microseconds since boot. Never goes backwards.
|
||||
// To define your own implementation, set MG_ENABLE_CUSTOM_MICROS=1
|
||||
uint64_t mg_micros(void);
|
||||
|
||||
// Return milliseconds since boot. Never goes backwards. Calls mg_micros().
|
||||
// To define your own implementation, set MG_ENABLE_CUSTOM_MILLIS=1
|
||||
// Deprecated: use mg_micros() instead.
|
||||
uint64_t mg_millis(void);
|
||||
|
||||
// Checks whether a periodic deadline has expired.
|
||||
//
|
||||
// Returns:
|
||||
// True when the timer has fired; false otherwise.
|
||||
// Example:
|
||||
// uint64_t timer = 0;
|
||||
// if (mg_timer_expired(&timer, 1000, mg_millis())) {
|
||||
// MG_INFO(("every second"));
|
||||
// }
|
||||
// Full examples:
|
||||
// tutorials/mqtt/mqtt-client
|
||||
// Related APIs:
|
||||
// mg_millis(), mg_now()
|
||||
// Notes:
|
||||
// Initialise *expiration to 0 before first use. On expiry, this function
|
||||
// advances *expiration by period and handles time wrap-around.
|
||||
bool mg_timer_expired(uint64_t *expiration, uint64_t period, uint64_t now);
|
||||
|
||||
struct mg_timer {
|
||||
uint64_t period_ms; // Timer period in milliseconds
|
||||
uint64_t expire; // Expiration timestamp in milliseconds
|
||||
@@ -3475,20 +3502,12 @@ size_t mg_ws_wrap(struct mg_connection *, size_t len, int op);
|
||||
size_t mg_ws_printf(struct mg_connection *c, int op, const char *fmt, ...);
|
||||
size_t mg_ws_vprintf(struct mg_connection *c, int op, const char *fmt,
|
||||
va_list *);
|
||||
// Time / SNTP functions
|
||||
// SNTP functions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Return microseconds since boot. Never goes backwards.
|
||||
// To define your own implementation, set MG_ENABLE_CUSTOM_MICROS=1
|
||||
uint64_t mg_micros(void);
|
||||
|
||||
// Return milliseconds since boot. Never goes backwards. Calls mg_micros().
|
||||
// To define your own implementation, set MG_ENABLE_CUSTOM_MILLIS=1
|
||||
// Deprecated: use mg_micros() instead.
|
||||
uint64_t mg_millis(void);
|
||||
|
||||
// Boot timestamp in ms since Epoch. 0 until the first successful SNTP sync;
|
||||
// updated automatically by mg_sntp_connect() on each successful response.
|
||||
@@ -3498,24 +3517,6 @@ extern uint64_t mg_boot_timestamp_ms;
|
||||
// Until a successful SNTP request completes, this is identical to mg_millis().
|
||||
uint64_t mg_now(void);
|
||||
|
||||
// Checks whether a periodic deadline has expired.
|
||||
//
|
||||
// Returns:
|
||||
// True when the timer has fired; false otherwise.
|
||||
// Example:
|
||||
// uint64_t timer = 0;
|
||||
// if (mg_timer_expired(&timer, 1000, mg_millis())) {
|
||||
// MG_INFO(("every second"));
|
||||
// }
|
||||
// Full examples:
|
||||
// tutorials/mqtt/mqtt-client
|
||||
// Related APIs:
|
||||
// mg_millis(), mg_now()
|
||||
// Notes:
|
||||
// Initialise *expiration to 0 before first use. On expiry, this function
|
||||
// advances *expiration by period and handles time wrap-around.
|
||||
bool mg_timer_expired(uint64_t *expiration, uint64_t period, uint64_t now);
|
||||
|
||||
// Connect to an SNTP server and send a time request.
|
||||
// `url` defaults to "udp://time.google.com:123" when NULL.
|
||||
// On success the internal boot timestamp is updated so that mg_now() returns
|
||||
|
||||
Reference in new issue
Block a user