function lfds700_list_asu_link_end
Source Files
└───liblfds700 ├───inc │ └───liblfds700 │ lfds700_list_addonly_singlylinked_unordered.h └───src └───llfds700_list_addonly_singlylinked_unordered lfds700_list_addonly_singlylinked_unordered_insert.c
Opaque Structures
struct lfds700_list_asu_element; struct lfds700_list_asu_state; struct lfds700_misc_prng_state;
Prototype
void lfds700_list_asu_link_end( struct lfds700_list_asu_state *lasus, struct lfds700_list_asu_element *lasue, struct lfds700_misc_prng_state *ps );
Parameters
struct lfds700_list_asu_state *lasus
- A pointer to an initialized struct lfds700_list_asu_state.
struct lfds700_list_asu_element *lasue
- A pointer a user-allocated LFDS700_PAL_ATOMIC_ISOLATION_IN_BYTES aligned struct lfds700_list_asu_element. Stack declared variables will automatically be correctly aligned by the compiler, due to the information in the structure definitions; nothing has to be done. Heap allocated variables however will by no means be correctly aligned and an aligned malloc must be used.
struct lfds700_misc_prng_state *ps
- A pointer to an initialized struct lfds700_misc_prng_state.
Notes
This function takes a user allocated struct lfds700_list_asu_element and then links this element as the new end of the list. The list interally maintains a pointer to the current end element, so a full list traversal is not required.
Note however that this pointer to end is not - cannot - be updated atomically with the atomic linking of new elements into the list and as such it can be out of date, which is to say, pointing at an element which was at one point the last element but is no more. Whenever a list function is executed where that function needs to use the end pointer, it moves the end pointer to the correct location and then proceeds (to be more exact, these functions loop, moving the end pointer to what they think is the last element and then trying to proceed; they can only succeed if it turns out the end pointer really is pointing at the last element).
As such, it could be that some work is needed to move the end pointer to the correct location. However, the work to be done is equal to the number of new elements added to the list after whatever element the end pointer is pointing at, so in general it will be a huge improvement over a full list traversal.
Example
Coming soon. No, really! (Written 29th Dec 2015).