GNUnet 0.22.1
testing_api_cmd_barrier_create.c File Reference
#include "platform.h"
#include "gnunet_testing_lib.h"
#include "testing_api_barrier.h"
#include "testing_api_loop.h"
Include dependency graph for testing_api_cmd_barrier_create.c:

Go to the source code of this file.

Functions

static enum GNUNET_GenericReturnValue barrier_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 Offer internal data from a "barrier" CMD, to other commands. More...
 
static void barrier_cleanup (void *cls)
 Cleanup the state from a "barrier" CMD, and possibly cancel a pending operation thereof. More...
 
static void barrier_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 Run the command. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_barrier_create (const char *label, unsigned int number_to_be_reached)
 Command to create a barrier. More...
 

Function Documentation

◆ barrier_traits()

static enum GNUNET_GenericReturnValue barrier_traits ( void *  cls,
const void **  ret,
const char *  trait,
unsigned int  index 
)
static

Offer internal data from a "barrier" CMD, to other commands.

Parameters
clsclosure.
[out]retresult.
traitname of the trait.
indexindex number of the object to offer.
Returns
GNUNET_OK on success.

Definition at line 42 of file testing_api_cmd_barrier_create.c.

46{
47 struct GNUNET_TESTING_Trait traits[] = {
49 };
50
52 ret,
53 trait,
54 index);
55}
static int ret
Final status code.
Definition: gnunet-arm.c:93
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" of traits array.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Obtain value of a trait from a command.
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
unsigned int index
Index number associated with the trait.
static enum GNUNET_GenericReturnValue traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.

References GNUNET_TESTING_get_trait(), GNUNET_TESTING_trait_end(), GNUNET_TESTING_Trait::index, ret, and traits().

Referenced by GNUNET_TESTING_cmd_barrier_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ barrier_cleanup()

static void barrier_cleanup ( void *  cls)
static

Cleanup the state from a "barrier" CMD, and possibly cancel a pending operation thereof.

Parameters
clsclosure.

Definition at line 65 of file testing_api_cmd_barrier_create.c.

66{
67 struct GNUNET_TESTING_Barrier *barrier = cls;
68
69 GNUNET_free (barrier);
70}
#define GNUNET_free(ptr)
Wrapper around free.
An entry for a barrier list.

References GNUNET_free.

Referenced by GNUNET_TESTING_cmd_barrier_create().

Here is the caller graph for this function:

◆ barrier_run()

static void barrier_run ( void *  cls,
struct GNUNET_TESTING_Interpreter is 
)
static

Run the command.

Parameters
clsclosure.
isthe interpreter state.

Definition at line 80 of file testing_api_cmd_barrier_create.c.

82{
83 struct GNUNET_TESTING_Barrier *barrier = cls;
84
86 barrier);
87}
static struct GNUNET_TESTING_Interpreter * is
void GNUNET_TESTING_add_barrier_(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
Add a barrier to the interpreter to share it with all children as an inherited barrier.

References GNUNET_TESTING_add_barrier_(), and is.

Referenced by GNUNET_TESTING_cmd_barrier_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_cmd_barrier_create()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_barrier_create ( const char *  label,
unsigned int  number_to_be_reached 
)

Command to create a barrier.

Parameters
labelThe label of this command.
number_to_be_reachedIf this number of processes reached this barrier, all processes waiting at this barrier can pass it.

Definition at line 91 of file testing_api_cmd_barrier_create.c.

94{
95 struct GNUNET_TESTING_Barrier *barrier;
96
97 barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
99 &barrier->barrier_id);
100 barrier->expected_reaches = number_to_be_reached;
101 return GNUNET_TESTING_command_new (barrier,
102 label,
106}
#define GNUNET_TESTING_command_new(cls, label, run, cleanup, traits)
Create a new command.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_ShortHashCode barrier_id
unsigned int expected_reaches
Number of total commands expected to be reached by the barrier.
void GNUNET_TESTING_barrier_name_hash_(const char *barrier_name, struct GNUNET_ShortHashCode *bkey)
static enum GNUNET_GenericReturnValue barrier_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Offer internal data from a "barrier" CMD, to other commands.
static void barrier_cleanup(void *cls)
Cleanup the state from a "barrier" CMD, and possibly cancel a pending operation thereof.
static void barrier_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run the command.

References barrier_cleanup(), GNUNET_TESTING_Barrier::barrier_id, barrier_run(), barrier_traits(), GNUNET_TESTING_Barrier::expected_reaches, GNUNET_new, GNUNET_TESTING_barrier_name_hash_(), and GNUNET_TESTING_command_new.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function: