rlib
Convenience library for useful things
Loading...
Searching...
No Matches
rtimeoutcblist.h
Go to the documentation of this file.
1/* RLIB - Convenience library for useful things
2 * Copyright (C) 2016 Haakon Sporsheim <haakon.sporsheim@gmail.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3.0 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library.
16 * See the COPYING file at the root of the source repository.
17 */
18#ifndef __R_TIMEOUT_CBLIST_H__
19#define __R_TIMEOUT_CBLIST_H__
20
21#if !defined(__RLIB_H_INCLUDE_GUARD__) && !defined(RLIB_COMPILATION)
22#error "#include <rlib.h> only please."
23#endif
24
47#include <rlib/rtypes.h>
48#include <rlib/rref.h>
49
51
53typedef struct RToCB RToCB;
55#define r_to_cb_ref r_ref_ref
57#define r_to_cb_unref r_ref_unref
58
65typedef struct {
71
73#define R_TIMEOUT_CBLIST_INIT { NULL, NULL, 0 }
75#define r_timeout_cblist_init(lst) r_memset (lst, 0, sizeof (RTimeoutCBList))
76
84#define r_timeout_cblist_len(lst) (lst)->size
85
104 RToCB ** tocb, RClockTime ts, RFunc cb,
105 rpointer data, RDestroyNotify datanotify, rpointer user, RDestroyNotify usernotify);
130
131R_END_DECLS
132
135#endif /* __R_TIMEOUT_CBLIST_H__ */
136
#define R_API
Public-API decoration: resolves to R_API_EXPORT while building rlib and R_API_IMPORT for consumers.
Definition rmacros.h:115
#define R_BEGIN_DECLS
Open an extern "C" block under C++ (no-op in C).
Definition rmacros.h:196
RClockTime r_timeout_cblist_first_timeout(RTimeoutCBList *lst)
Return the deadline of the head entry, or R_CLOCK_TIME_NONE if the list is empty.
void r_timeout_cblist_clear(RTimeoutCBList *lst)
Cancel every pending entry and drop the list to empty.
rboolean r_timeout_cblist_insert(RTimeoutCBList *lst, RToCB **tocb, RClockTime ts, RFunc cb, rpointer data, RDestroyNotify datanotify, rpointer user, RDestroyNotify usernotify)
Schedule cb to fire at ts.
rboolean r_timeout_cblist_cancel(RTimeoutCBList *lst, RToCB *cb)
Cancel the entry identified by cb.
struct RToCB RToCB
Opaque, refcounted timeout-callback entry.
Definition rtimeoutcblist.h:53
rsize r_timeout_cblist_update(RTimeoutCBList *lst, RClockTime ts)
Fire and remove every entry whose deadline is at or before ts; returns the number called.
int rboolean
Boolean type (typedef'd to int).
Definition rtypes.h:59
void(* RFunc)(rpointer data, rpointer user)
Generic iteration callback over (data, user) pairs.
Definition rtypes.h:403
void(* RDestroyNotify)(rpointer ptr)
Destructor callback: free / release the value at ptr.
Definition rtypes.h:401
void * rpointer
Generic pointer (alias for void *).
Definition rtypes.h:327
unsigned long rsize
Unsigned pointer-sized size type (like size_t).
Definition rtypes.h:290
ruint64 RClockTime
Unsigned 64-bit timestamp / duration, in nanoseconds.
Definition rtypes.h:353
Refcount base struct shared by every refcounted type in rlib.
Foundational type aliases used by every rlib header.
Ordered list of RToCB entries keyed by deadline.
Definition rtimeoutcblist.h:65
RToCB * head
Definition rtimeoutcblist.h:66
rsize size
Definition rtimeoutcblist.h:69
RToCB * tail
Definition rtimeoutcblist.h:67