function lfds700_stack_push

From liblfds.org
Jump to navigation Jump to search

Source Files

└───liblfds700
    ├───inc
    │   └───liblfds700
    │           lfds700_stack.h
    └───src
        └───lfds700_stack
                lfds700_stack_push.c

Opaque Structures

struct lfds700_misc_prng_state;
struct lfds700_stack_element;
struct lfds700_stack_state;

Prototype

void lfds700_stack_push( struct lfds700_stack_state *ss,
                         struct lfds700_stack_element *se,
                         struct lfds700_misc_prng_state *ps );

Parameters

struct lfds700_stack_state *ss

A pointer to an initialized struct lfds700_stack_state.

struct lfds700_stack_element *se

A pointer to a user-allocated struct lfds700_stack_element. There are no alignment requirements for this structure.

struct lfds700_misc_prng_state *ps

A pointer to an initialized struct lfds700_misc_prng_state.

Notes

This function pushes a stack element, with its key and value, onto the stack. The key and value are both optional, are set by the macros LFDS700_STACK_SET_KEY_IN_ELEMENT and LFDS700_STACK_SET_VALUE_IN_ELEMENT respectively, and can only be set when a stack element is outside of a stack.

The third argument, the struct lfds700_misc_prng_state, is the state for a single-threaded, fast, high quality random number generator, required by the exponential backoff code. Each thread should allocate and initialize one of these structures, and then it can be used for all API calls which take this argument.

Example

#include "liblfds700.h"

int main()
{
  char
    name[64] = "Bob the Skutter";

  struct lfds700_misc_prng_state
    ps;

  struct lfds700_stack_element
    se;

  struct lfds700_stack_state
    ss;

  lfds700_misc_library_init_valid_on_current_logical_core();

  lfds700_misc_prng_init( &ps );

  lfds700_stack_init_valid_on_current_logical_core( &ss, NULL );

  LFDS700_STACK_SET_VALUE_IN_ELEMENT( se, name );
  lfds700_stack_push( &ss, &se, &ps );

  lfds700_stack_cleanup( &ss, NULL );

  lfds700_misc_library_cleanup();

  return( EXIT_SUCCESS );
}

See Also