Freeciv-3.3
Loading...
Searching...
No Matches
Macros | Enumerations | Functions
timing.h File Reference
#include "support.h"
#include "speclist.h"

Go to the source code of this file.

Macros

#define LOG_TIMERS
 
#define TIMER_DEBUG   TIMER_IGNORE
 
#define SPECLIST_TAG   timer
 
#define SPECLIST_TYPE   struct timer
 
#define timer_list_iterate(ARG_list, NAME_item)    TYPED_LIST_ITERATE(struct timer, (ARG_list), NAME_item)
 
#define timer_list_iterate_end   LIST_ITERATE_END
 

Enumerations

enum  timer_timetype { TIMER_CPU , TIMER_USER }
 
enum  timer_use { TIMER_ACTIVE , TIMER_IGNORE }
 

Functions

struct timertimer_new (enum timer_timetype type, enum timer_use use, const char *name)
 
struct timertimer_renew (struct timer *t, enum timer_timetype type, enum timer_use use, const char *name)
 
void timer_destroy (struct timer *t)
 
bool timer_in_use (struct timer *t)
 
void timer_clear (struct timer *t) fc__attribute((nonnull(1)))
 
void timer_start (struct timer *t) fc__attribute((nonnull(1)))
 
void timer_stop (struct timer *t) fc__attribute((nonnull(1)))
 
double timer_read_seconds (struct timer *t) fc__attribute((nonnull(1)))
 
void timer_usleep_since_start (struct timer *t, long usec) fc__attribute((nonnull(1)))
 

Macro Definition Documentation

◆ LOG_TIMERS

#define LOG_TIMERS

Definition at line 31 of file timing.h.

◆ SPECLIST_TAG

#define SPECLIST_TAG   timer

Definition at line 66 of file timing.h.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct timer

Definition at line 67 of file timing.h.

◆ TIMER_DEBUG

#define TIMER_DEBUG   TIMER_IGNORE

Definition at line 61 of file timing.h.

◆ timer_list_iterate

#define timer_list_iterate (   ARG_list,
  NAME_item 
)     TYPED_LIST_ITERATE(struct timer, (ARG_list), NAME_item)

Definition at line 69 of file timing.h.

◆ timer_list_iterate_end

#define timer_list_iterate_end   LIST_ITERATE_END

Definition at line 71 of file timing.h.

Enumeration Type Documentation

◆ timer_timetype

Enumerator
TIMER_CPU 
TIMER_USER 

Definition at line 40 of file timing.h.

◆ timer_use

Enumerator
TIMER_ACTIVE 
TIMER_IGNORE 

Definition at line 45 of file timing.h.

Function Documentation

◆ timer_clear()

void timer_clear ( struct timer t)

Reset accumulated time to zero, and stop timer if going. That is, this may be called whether t is started or stopped; in either case the timer is in the stopped state after this function.

Definition at line 252 of file timing.c.

Referenced by send_server_info_to_metaserver(), srv_running(), timer_renew(), and timing_log_real().

◆ timer_destroy()

void timer_destroy ( struct timer t)

◆ timer_in_use()

bool timer_in_use ( struct timer t)

Return whether timer is in use. t may be nullptr, in which case returns FALSE

Definition at line 242 of file timing.c.

Referenced by auto_workers_player().

◆ timer_new()

struct timer * timer_new ( enum timer_timetype  type,
enum timer_use  use,
const char name 
)

Allocate a new timer with specified "type" and "use". The timer is created as cleared, and stopped.

Definition at line 160 of file timing.c.

Referenced by cm_init(), connection_ping(), dai_manage_taxes(), load_command(), mapimg_create(), register_agent(), save_game(), savegame3_save(), savegame_load(), send_server_info_to_metaserver(), server_make_connection(), srv_prepare(), and timing_log_init().

◆ timer_read_seconds()

double timer_read_seconds ( struct timer t)

◆ timer_renew()

struct timer * timer_renew ( struct timer t,
enum timer_timetype  type,
enum timer_use  use,
const char name 
)

Allocate a new timer, or reuse t, with specified "type" and "use". The timer is created as cleared, and stopped. If t is nullptr, allocate and return a new timer, else just re-initialise t and return t. This is intended to be useful to allocate a static t just once, eg: { static struct timer *t = nullptr; t = timer_renew(t, TIMER_CPU, TIMER_USE, "example"); ... stuff ... log_verbose("That took %g seconds.", timer_read_seconds(t)); ... never free t ... }

Definition at line 180 of file timing.c.

Referenced by anim_timer_renew(), auto_workers_player(), autosaves_callback(), begin_phase(), blink_active_unit(), blink_turn_done_button(), cma_init(), incoming_client_packets(), server_sniff_all_input(), set_seconds_to_turndone(), srv_running(), start_turn_change_wait(), timer_new(), and write_socket_data().

◆ timer_start()

void timer_start ( struct timer t)

◆ timer_stop()

void timer_stop ( struct timer t)

Stop timing, and accumulate time so far. (The current time is stored in t->start, so that timer_read_seconds can call this to take a point reading if the timer is active.) A warning is printed if the timer is already stopped.

Definition at line 305 of file timing.c.

Referenced by autosaves_callback(), dai_manage_taxes(), end_search(), savegame3_save(), savegame_load(), timer_read_seconds(), timing_log_real(), and wait_for_requests().

◆ timer_usleep_since_start()

void timer_usleep_since_start ( struct timer t,
long  usec 
)

Sleeps until the given number of microseconds have elapsed since the timer was started. Leaves the timer running. Must be called with an active, running user timer. (If timer is broken or in wrong state, just sleep for entire interval.)

Definition at line 398 of file timing.c.

Referenced by decrease_unit_hp_smooth().