Difference between pages "r7.1.0:Macro LFDS710 QUEUE BSS GET USER STATE FROM STATE" and "r7.1.0:Macro LFDS710 QUEUE UMM GET KEY FROM ELEMENT"

From liblfds.org
(Difference between pages)
Jump to navigation Jump to search
 
 
Line 1: Line 1:
{{DISPLAYTITLE:macro LFDS710_QUEUE_BSS_GET_USER_STATE_FROM_STATE}}
{{DISPLAYTITLE:macro LFDS710_QUEUE_UMM_GET_KEY_FROM_ELEMENT}}
==Source File==
==Source Files==
  └───liblfds710
  └───liblfds710
     └───inc
     └───inc
         └───liblfds710
         └───liblfds710
                 lfds710_queue_bounded_singleproducer_singleconsumer.h
                 lfds710_queue_umm.h
 
==Opaque Structures==
struct [[r7.1.0:struct lfds710_queue_umm_element|lfds710_queue_umm_element]];


==Macro==
==Macro==
  #define LFDS710_QUEUE_BSS_GET_USER_STATE_FROM_STATE( queue_bss_state )
  #define LFDS710_QUEUE_GET_KEY_FROM_ELEMENT( queue_umm_element )


==Parameters==
==Parameters==
''queue_bss_state''
''queue_umm_element''
: An initialized ''struct lfds710_queue_bss_state''.  Not a pointer to it - the struct itself.
: A ''struct lfds710_queue_umm_element''.  Not a pointer to it - the struct itself.


==Return Value==
==Return Value==
Returns a ''void *'', the ''user_state'' argument from ''[[r7.1.0:function lfds710_queue_bss_init_valid_on_current_logical_core|lfds710_queue_bss_init_valid_on_current_logical_core]]''.
Returns a void pointer, the key from the element.


==Notes==
==Notes==
The user state value can only be set the once, when the data structure instance is initialized.
The key set into a queue element is only guranteed to be visible to another logical core once the element has been dequeued by a thread running on that logical core.
 
So, for example, if there was a globally allocated queue element, where a thread on logical core A set a value and then enqueued the element to the queue, a thread on logical core B would only be guaranteed to see the key set by the other thread once it dequeues the element from the queue.


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 key is not used in any way by the queue, and is provided for convenience when moving keys and values between different data structures.


==Example==
==Example==
#include "liblfds710.h"
Coming soonNo, really! (Written 29th Dec 2015).
#include <stdio.h>
#include <string.h>
int main()
{
  char
    queue_bss_name[64] = "Idiot Prayer";
  struct lfds710_queue_bss_element
    element_array[64];
  struct lfds710_queue_bss_state
    qbsss;
  void
    *user_state;
  lfds710_queue_bss_init_valid_on_current_logical_core( &qbsss, element_array, 64, (void *) queue_bss_name );
   
  user_state = LFDS710_QUEUE_BSS_GET_USER_STATE_FROM_STATE( qbsss );
  printf( "queue_bss name is \"%s\"\n", (char *) user_state );
   
  lfds710_queue_bss_cleanup( &qbsss, NULL );
  return( EXIT_SUCCESS );
}


==See Also==
==See Also==
* [[r7.1.0:Queue (bounded, single producer, single consumer)|Queue (bounded, single producer, single consumer)]]
* [[r7.1.0:Queue (unbounded, many producer, many consumer)|Queue (unbounded, many producer, many consumer)]]
* ''[[r7.1.0:macro LFDS710_QUEUE_UMM_SET_KEY_IN_ELEMENT|LFDS710_QUEUE_UMM_SET_KEY_IN_ELEMENT]]''

Latest revision as of 14:43, 8 May 2016

Source Files

└───liblfds710
    └───inc
        └───liblfds710
                lfds710_queue_umm.h

Opaque Structures

struct lfds710_queue_umm_element;

Macro

#define LFDS710_QUEUE_GET_KEY_FROM_ELEMENT( queue_umm_element )

Parameters

queue_umm_element

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

Return Value

Returns a void pointer, the key from the element.

Notes

The key set into a queue element is only guranteed to be visible to another logical core once the element has been dequeued by a thread running on that logical core.

So, for example, if there was a globally allocated queue element, where a thread on logical core A set a value and then enqueued the element to the queue, a thread on logical core B would only be guaranteed to see the key set by the other thread once it dequeues the element from the queue.

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

The key is not used in any way by the queue, and is provided for convenience when moving keys and values between different data structures.

Example

Coming soon. No, really! (Written 29th Dec 2015).

See Also