Implements SyncWaitlist.
SyncWaitlist impl | Implements SyncWaitlist. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file SyncWaitlist. |
C-kern/ | Implementation file SyncWaitlist impl. |
Types | |
struct wlistentry_t | Export wlistentry_t into global namespace. |
wlistentry_t | Type of entry stored in syncwlist_t. |
Macros | |
wlistentry_FREE | Static initializer. |
Functions | |
initmove_wlistentry | Moves src to dest. |
syncwlist_t | |
static variables | |
s_syncwlist_errtimer | Allows to introduce artificial errors during test. |
helper | |
dlist_IMPLEMENT _wlist | Implements interface to manage wlistentry_t in a double linked list of type dlist_t. |
compiletime_assert | Ensures that syncwlist_t and wlistentry_t can be cast into dlist_node_t without changing the address of the pointer. |
lifetime | |
init_syncwlist | The double linked list dlist_t will not be stored. |
query | |
update | |
syncwlist_iterator_t | |
test |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2013 Jörg Seebohn
Header file SyncWaitlist.
Implementation file SyncWaitlist impl.
typedef struct wlistentry_t wlistentry_t
Export wlistentry_t into global namespace.
struct wlistentry_t
Type of entry stored in syncwlist_t. It embeds a dlist_node_t and a syncevent_t.
Macros | |
wlistentry_FREE | Static initializer. |
Functions | |
initmove_wlistentry | Moves src to dest. |
static variables | |
s_syncwlist_errtimer | Allows to introduce artificial errors during test. |
helper | |
dlist_IMPLEMENT _wlist | Implements interface to manage wlistentry_t in a double linked list of type dlist_t. |
compiletime_assert | Ensures that syncwlist_t and wlistentry_t can be cast into dlist_node_t without changing the address of the pointer. |
lifetime | |
init_syncwlist | The double linked list dlist_t will not be stored. |
query | |
update |
Implements interface to manage wlistentry_t in a double linked list of type dlist_t. The generated functions have name YYY_wlist (init_wlist...) instead of YYY_dlist (init_dlist...).
static inline void compiletime_assert( void )
Ensures that syncwlist_t and wlistentry_t can be cast into dlist_node_t without changing the address of the pointer. This also ensures that syncwlist_t can be cast into wlistentry_t.
void init_syncwlist( /*out*/syncwlist_t * wlist )
The double linked list dlist_t will not be stored. Instead wlist is considered as the last node in it and therefore has a prev and next pointer instead of a single last pointer. This allows to move objects of type wlistentry_t in their queue and to fill any gaps created during removal of nodes. If a node is removed from the queue function <initmove_wlistentry> is called during execution of remove_syncqueue which allows to compact memory.
If the moved node would be the last node of a dlist_t the last pointer would become invalid. But making wlist part of the list (as dummy node) function <initmove_wlistentry> will adapt the pointers prev or next in case a node will be moved before or after node wlist.
Export wlistentry_t into global namespace.
typedef struct wlistentry_t wlistentry_t
Type of entry stored in syncwlist_t.
struct wlistentry_t
Static initializer.
#define wlistentry_FREE { 0, 0, syncevent_FREE }
Moves src to dest.
void initmove_wlistentry( /*out*/wlistentry_t * dest, wlistentry_t * src )
Allows to introduce artificial errors during test.
static test_errortimer_t s_syncwlist_errtimer
Double linked circular list.
struct dlist_t
Ensures that syncwlist_t and wlistentry_t can be cast into dlist_node_t without changing the address of the pointer.
static inline void compiletime_assert( void )
Provides the means for linking an object to two others of the same type.
struct dlist_node_t
The double linked list dlist_t will not be stored.
void init_syncwlist( /*out*/syncwlist_t * wlist )
Event type stores a pointer to a single waiting syncwait_t.
struct syncevent_t
Implements syncqueue_t.remove_syncqueue.
#define remove_syncqueue( syncqueue, elem, initmove_elem ) ( __extension__ ({ syncqueue_t * _sq = (syncqueue) ; typeof(elem) _elem = (elem) ; typeof(elem) _lastentry = last_queue( genericcast_queue(_sq), sizeof(*_elem)) ; if (_lastentry && _lastentry != _elem) { (initmove_elem)(_elem, _lastentry) ; } int _err = removelast_queue( genericcast_queue(_sq), sizeof(*_elem)) ; _sq->nrelements -= (_err == 0) ; _err ; }))