Difference between pages "r7.1.1:Macro LFDS711 QUEUE UMM GET KEY FROM ELEMENT" and "r7.1.1:Macro LFDS711 QUEUE UMM GET USER STATE FROM STATE"

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_QUEUE_UMM_GET_KEY_FROM_ELEMENT}}
{{DISPLAYTITLE:macro LFDS711_QUEUE_UMM_GET_USER_STATE_FROM_STATE}}
==Source Files==
==Source File==
  └───liblfds711
  └───liblfds711
     └───inc
     └───inc
         └───liblfds711
         └───liblfds711
                 lfds711_queue_umm.h
                 lfds711_queue_umm.h
==Opaque Structures==
struct [[r7.1.1:struct lfds711_queue_umm_element|lfds711_queue_umm_element]];


==Macro==
==Macro==
  #define LFDS711_QUEUE_GET_KEY_FROM_ELEMENT( queue_umm_element )
  #define LFDS711_QUEUE_UMM_GET_USER_STATE_FROM_STATE( queue_umm_state )


==Parameters==
==Parameters==
''queue_umm_element''
''queue_umm_state''
: A ''struct lfds711_queue_umm_element''.  Not a pointer to it - the struct itself.
: An initialized ''struct lfds711_queue_umm_state''.  Not a pointer to it - the struct itself.


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


==Notes==
==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.
The user state value can only be set the once, when the data structure instance is initialized.
 
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==
Coming soon.  No, really! (Written 29th Dec 2015).
#include <stdio.h>
#include <string.h>
#include "liblfds711.h"
int main()
  {
  char
    queue_name[64] = "People Ain't No Good";
  struct lfds711_queue_umm_element
    qumme_dummy;
 
  struct lfds711_queue_umm_state
    qumms;
  void
    *user_state;
  lfds711_queue_umm_init_valid_on_current_logical_core( &qumms, &qumme_dummy, (void *) queue_name );
  user_state = LFDS711_QUEUE_GET_USER_STATE_FROM_STATE( qumms );
  printf( "queue name is \"%s\"\n", (char *) user_state );
  lfds711_queue_umm_cleanup( &qumms, NULL );
   
  return( EXIT_SUCCESS );
}


==See Also==
==See Also==
* [[r7.1.1:Queue (unbounded, many producer, many consumer)|Queue (unbounded, many producer, many consumer)]]
* [[r7.1.1:Queue (unbounded, many producer, many consumer)|Queue (unbounded, many producer, many consumer)]]
* ''[[r7.1.1:macro LFDS711_QUEUE_UMM_SET_KEY_IN_ELEMENT|LFDS711_QUEUE_UMM_SET_KEY_IN_ELEMENT]]''

Latest revision as of 18:12, 16 February 2017

Source File

└───liblfds711
    └───inc
        └───liblfds711
                lfds711_queue_umm.h

Macro

#define LFDS711_QUEUE_UMM_GET_USER_STATE_FROM_STATE( queue_umm_state )

Parameters

queue_umm_state

An initialized struct lfds711_queue_umm_state. Not a pointer to it - the struct itself.

Return Value

Returns a void *, the user_state argument from lfds711_umm_queue_init_valid_on_current_logical_core.

Notes

The user state value can only be set the once, when the data structure instance is initialized.

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

Example

#include <stdio.h>
#include <string.h>
#include "liblfds711.h"

int main()
{
  char
    queue_name[64] = "People Ain't No Good";

  struct lfds711_queue_umm_element
    qumme_dummy;
 
  struct lfds711_queue_umm_state
    qumms;

  void
    *user_state;

  lfds711_queue_umm_init_valid_on_current_logical_core( &qumms, &qumme_dummy, (void *) queue_name );

  user_state = LFDS711_QUEUE_GET_USER_STATE_FROM_STATE( qumms );

  printf( "queue name is \"%s\"\n", (char *) user_state );

  lfds711_queue_umm_cleanup( &qumms, NULL );

  return( EXIT_SUCCESS );
}

See Also