Freeciv-3.3: /fast/freeciv/nightly/main/utility/timing.h File Reference

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 timer * | timer_new (enum timer_timetype type, enum timer_use use, const char *name)
struct timer * | timer_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)
void | timer_start (struct timer *t)
void | timer_stop (struct timer *t)
double | timer_read_seconds (struct timer *t)
void | timer_usleep_since_start (struct timer *t, long usec)

## 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

enum timer_timetype

Enumerator
TIMER_CPU |
TIMER_USER |

Definition at line 40 of file timing.h.

## ◆ timer_use

enum 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 | ) |

Free the memory associated with a timer.

Definition at line 208 of file timing.c.

Referenced by adv_workers_free(), agents_free(), autosaves_callback(), cm_free(), connection_common_close(), dai_manage_taxes(), incoming_client_packets(), load_command(), mapimg_create(), save_game(), savegame3_save(), savegame_load(), send_server_info_to_metaserver(), server_make_connection(), server_quit(), signal_timer_free(), srv_running(), and timing_log_free().

## ◆ timer_in_use()

bool timer_in_use | ( | struct timer * | t | ) |

Return whether timer is in use. t may be NULL, 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 | ) |

Read value from timer. If the timer is not stopped, this stops the timer, reads it (and accumulates), and then restarts it. Returns 0.0 for unused timers.

Definition at line 384 of file timing.c.

Referenced by auto_workers_player(), blink_active_unit(), blink_turn_done_button(), cut_lagging_connection(), dai_manage_taxes(), handle_conn_pong(), incoming_client_packets(), increase_timeout_because_unit_moved(), load_command(), mapimg_create(), move_unit_map_canvas(), real_timer_callback(), save_game(), savegame3_save(), savegame_load(), send_game_info(), send_server_info_to_metaserver(), server_sniff_all_input(), set_mapview_origin(), sg_save_game(), srv_running(), update_animation(), and wait_for_requests().

## ◆ 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 NULL, 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 = NULL; 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 | ) |

Start timing, adding to previous accumulated time if timer has not been cleared. A warning is printed if the timer is already started.

Definition at line 264 of file timing.c.

Referenced by anim_timer_renew(), auto_workers_player(), autosaves_callback(), begin_phase(), begin_search(), blink_active_unit(), blink_turn_done_button(), connection_ping(), dai_manage_taxes(), incoming_client_packets(), load_command(), mapimg_create(), save_game(), savegame3_save(), savegame_load(), send_server_info_to_metaserver(), server_make_connection(), server_sniff_all_input(), set_seconds_to_turndone(), srv_running(), start_turn_change_wait(), timing_log_real(), wait_for_requests(), and write_socket_data().

## ◆ 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 308 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 405 of file timing.c.

Referenced by decrease_unit_hp_smooth().