version 1.1.1.1, 2016/10/18 13:28:18
|
version 1.1.1.2, 2021/03/17 00:36:46
|
Line 30
|
Line 30
|
#ifndef __TIMER_H |
#ifndef __TIMER_H |
#define __TIMER_H |
#define __TIMER_H |
|
|
|
#include <time.h> |
#include <sys/time.h> |
#include <sys/time.h> |
|
|
|
#include "iperf_time.h" |
|
|
/* TimerClientData is an opaque value that tags along with a timer. The |
/* TimerClientData is an opaque value that tags along with a timer. The |
** client can use it for whatever, and it gets passed to the callback when |
** client can use it for whatever, and it gets passed to the callback when |
** the timer triggers. |
** the timer triggers. |
Line 46 typedef union
|
Line 49 typedef union
|
extern TimerClientData JunkClientData; /* for use when you don't care */ |
extern TimerClientData JunkClientData; /* for use when you don't care */ |
|
|
/* The TimerProc gets called when the timer expires. It gets passed |
/* The TimerProc gets called when the timer expires. It gets passed |
** the TimerClientData associated with the timer, and a timeval in case | ** the TimerClientData associated with the timer, and a iperf_time in case |
** it wants to schedule another timer. |
** it wants to schedule another timer. |
*/ |
*/ |
typedef void TimerProc( TimerClientData client_data, struct timeval* nowP ); | typedef void TimerProc( TimerClientData client_data, struct iperf_time* nowP ); |
|
|
/* The Timer struct. */ |
/* The Timer struct. */ |
typedef struct TimerStruct |
typedef struct TimerStruct |
Line 58 typedef struct TimerStruct
|
Line 61 typedef struct TimerStruct
|
TimerClientData client_data; |
TimerClientData client_data; |
int64_t usecs; |
int64_t usecs; |
int periodic; |
int periodic; |
struct timeval time; | struct iperf_time time; |
struct TimerStruct* prev; |
struct TimerStruct* prev; |
struct TimerStruct* next; |
struct TimerStruct* next; |
int hash; |
int hash; |
Line 66 typedef struct TimerStruct
|
Line 69 typedef struct TimerStruct
|
|
|
/* Set up a timer, either periodic or one-shot. Returns (Timer*) 0 on errors. */ |
/* Set up a timer, either periodic or one-shot. Returns (Timer*) 0 on errors. */ |
extern Timer* tmr_create( |
extern Timer* tmr_create( |
struct timeval* nowP, TimerProc* timer_proc, TimerClientData client_data, | struct iperf_time* nowP, TimerProc* timer_proc, TimerClientData client_data, |
int64_t usecs, int periodic ); |
int64_t usecs, int periodic ); |
|
|
/* Returns a timeout indicating how long until the next timer triggers. You |
/* Returns a timeout indicating how long until the next timer triggers. You |
** can just put the call to this routine right in your select(). Returns |
** can just put the call to this routine right in your select(). Returns |
** (struct timeval*) 0 if no timers are pending. |
** (struct timeval*) 0 if no timers are pending. |
*/ |
*/ |
extern struct timeval* tmr_timeout( struct timeval* nowP ) /* __attribute__((hot)) */; | extern struct timeval* tmr_timeout( struct iperf_time* nowP ) /* __attribute__((hot)) */; |
|
|
/* Run the list of timers. Your main program needs to call this every so often, |
/* Run the list of timers. Your main program needs to call this every so often, |
** or as indicated by tmr_timeout(). |
** or as indicated by tmr_timeout(). |
*/ |
*/ |
extern void tmr_run( struct timeval* nowP ) /* __attribute__((hot)) */; | extern void tmr_run( struct iperf_time* nowP ) /* __attribute__((hot)) */; |
|
|
/* Reset the clock on a timer, to current time plus the original timeout. */ |
/* Reset the clock on a timer, to current time plus the original timeout. */ |
extern void tmr_reset( struct timeval* nowP, Timer* timer ); | extern void tmr_reset( struct iperf_time* nowP, Timer* timer ); |
|
|
/* Deschedule a timer. Note that non-periodic timers are automatically |
/* Deschedule a timer. Note that non-periodic timers are automatically |
** descheduled when they run, so you don't have to call this on them. |
** descheduled when they run, so you don't have to call this on them. |