GNUnet  0.10.x
Functions
speedup.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Start task that may speed up our system clock artificially. More...
 
void GNUNET_SPEEDUP_stop_ (void)
 Stop tasks that modify clock behavior. More...
 

Function Documentation

◆ GNUNET_SPEEDUP_start_()

int GNUNET_SPEEDUP_start_ ( const struct GNUNET_CONFIGURATION_Handle cfg)

Start task that may speed up our system clock artificially.

Parameters
cfgconfiguration to use
Returns
GNUNET_OK on success, GNUNET_SYSERR if the speedup was not configured
Parameters
cfgconfiguration to use
Returns
GNUNET_OK on success, GNUNET_SYSERR if the speedup was not configured

Definition at line 65 of file speedup.c.

References delta, do_speedup(), GNUNET_assert, GNUNET_CONFIGURATION_get_value_time(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now_with_lifeness(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, interval, LOG, and GNUNET_TIME_Relative::rel_value_us.

Referenced by program_main().

66 {
67  GNUNET_assert(NULL == speedup_task);
68  if (GNUNET_OK !=
70  "testing",
71  "SPEEDUP_INTERVAL",
72  &interval))
73  return GNUNET_SYSERR;
74  if (GNUNET_OK !=
76  "testing",
77  "SPEEDUP_DELTA",
78  &delta))
79  return GNUNET_SYSERR;
80 
81  if ((0 == interval.rel_value_us) ||
82  (0 == delta.rel_value_us))
83  {
85  "Speed up disabled\n");
86  return GNUNET_OK;
87  }
89  "Speed up execution by %s\n",
92  "Speed up executed every %s\n",
95  &do_speedup,
96  NULL);
97  return GNUNET_OK;
98 }
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
uint64_t rel_value_us
The actual value.
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_Task * speedup_task
Definition: speedup.c:37
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static void do_speedup(void *cls)
Definition: speedup.c:41
#define LOG(kind,...)
Definition: speedup.c:30
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now_with_lifeness(int lifeness, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible with the (transitive) ignore-shutdown flag either e...
Definition: scheduler.c:1331
static struct GNUNET_TIME_Relative interval
Definition: speedup.c:33
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:686
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SPEEDUP_stop_()

void GNUNET_SPEEDUP_stop_ ( void  )

Stop tasks that modify clock behavior.

Definition at line 105 of file speedup.c.

References delta, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_cancel(), interval, LOG, and GNUNET_TIME_Relative::rel_value_us.

Referenced by GNUNET_SERVICE_run_(), and shutdown_task().

106 {
107  if (NULL != speedup_task)
108  {
110  speedup_task = NULL;
111  }
112  if ((0 != interval.rel_value_us) &&
113  (0 != delta.rel_value_us))
115  "Stopped execution speed up\n");
116 }
uint64_t rel_value_us
The actual value.
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
static struct GNUNET_SCHEDULER_Task * speedup_task
Definition: speedup.c:37
#define LOG(kind,...)
Definition: speedup.c:30
static struct GNUNET_TIME_Relative interval
Definition: speedup.c:33
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function: