Difference between pages "r7.1.1:Macro LFDS711 LIST ASU GET VALUE FROM ELEMENT" and "r7.1.1:Macro LFDS711 LIST ASU SET KEY IN ELEMENT"

From liblfds.org
(Difference between pages)
Jump to navigation Jump to search
m (1 revision imported)
 
m (1 revision imported)
 
Line 1: Line 1:
{{DISPLAYTITLE:macro LFDS711_LIST_ASU_GET_VALUE_FROM_ELEMENT}}
{{DISPLAYTITLE:macro LFDS711_LIST_ASU_SET_KEY_IN_ELEMENT}}
==Source File==
==Source File==
  └───liblfds711
  └───liblfds711
Line 10: Line 10:


==Macro==
==Macro==
  #define LFDS711_LIST_ASU_GET_VALUE_FROM_ELEMENT( list_asu_element )
  #define LFDS711_LIST_ASU_SET_KEY_IN_ELEMENT( list_asu_element, new_key )


==Parameters==
==Parameters==
''list_asu_element''
''list_asu_element''
: A ''struct lfds711_list_asu_element''.  Not a pointer to it - the struct itself.
: A ''struct lfds711_list_asu_element''.  Not a pointer to it - the struct itself.
''new_key''
: A void pointer, which the key in ''list_asu_element'' is set to.


==Return Value==
==Return Value==
Returns a void pointer, the value from the element.
No return value.


==Notes==
==Notes==
As with all ''liblfds'' macros, the macro operates on the structure itself, not a pointer to it.
As with all ''liblfds'' macros, the macro operates on the structure itself, not a pointer to it.


The value in an element is set and set atomically by ''LFDS711_LIST_ASU_SET_VALUE_IN_ELEMENT'' and this get macro issues a load barrier before reading, which ensures that by the time ''LFDS711_LIST_ASU_SET_VALUE_IN_ELEMENT'' returns, the value set will be seen by all readers.
The key can only be set before an element enters the list.  If it is set after, the list will likely be broken (as the new key, being different to the old key, would most likely require the element to be in a different position in the tree, and this element movement is not supported) and also, key is not set atomically, so that even if a change was made, there is in principle no guarantee any other logical core would see that change anyway.


This contrasts to the bouded, single consumer, single producer queue, which only guarantees that the order of queuing will be honoured; it does not guarantee that by the time the enqueue function returns, readers will be able to dequeue the newly enqueued element.
Key is not set atomically because it is known it will only be set before an element enters the tree.  Matters can be (and have been) arranged to ensure key is despite the lack of an atomic set correctly propagated to other logical cores, but this is a behaviour of the linking code, not of the macro which sets key.


==Example==
==Example==

Latest revision as of 18:12, 16 February 2017

Source File

└───liblfds711
    └───inc
        └───liblfds711
                lfds711_list_addonly_singlylinked_unordered.h

Opaque Structures

struct lfds711_list_asu_element;

Macro

#define LFDS711_LIST_ASU_SET_KEY_IN_ELEMENT( list_asu_element, new_key )

Parameters

list_asu_element

A struct lfds711_list_asu_element. Not a pointer to it - the struct itself.

new_key

A void pointer, which the key in list_asu_element is set to.

Return Value

No return value.

Notes

As with all liblfds macros, the macro operates on the structure itself, not a pointer to it.

The key can only be set before an element enters the list. If it is set after, the list will likely be broken (as the new key, being different to the old key, would most likely require the element to be in a different position in the tree, and this element movement is not supported) and also, key is not set atomically, so that even if a change was made, there is in principle no guarantee any other logical core would see that change anyway.

Key is not set atomically because it is known it will only be set before an element enters the tree. Matters can be (and have been) arranged to ensure key is despite the lack of an atomic set correctly propagated to other logical cores, but this is a behaviour of the linking code, not of the macro which sets key.

Example

See Also