Freeciv-3.2
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
update_queue.c File Reference
#include "log.h"
#include "support.h"
#include "city.h"
#include "connection.h"
#include "player.h"
#include "canvas_g.h"
#include "citydlg_g.h"
#include "cityrep_g.h"
#include "dialogs_g.h"
#include "gui_main_g.h"
#include "menu_g.h"
#include "pages_g.h"
#include "plrdlg_g.h"
#include "ratesdlg_g.h"
#include "repodlgs_g.h"
#include "client_main.h"
#include "connectdlg_common.h"
#include "options.h"
#include "tilespec.h"
#include "zoom.h"
#include "update_queue.h"
#include "spechash.h"
#include "speclist.h"

Go to the source code of this file.

Data Structures

struct  update_queue_data
 
struct  waiting_queue_data
 

Macros

#define SPECHASH_TAG   update_queue
 
#define SPECHASH_IKEY_TYPE   uq_callback_t
 
#define SPECHASH_IDATA_TYPE   struct update_queue_data *
 
#define SPECHASH_IDATA_FREE   update_queue_data_destroy
 
#define update_queue_hash_iterate(hash, callback, uq_data)
 
#define update_queue_hash_iterate_end   HASH_ITERATE_END
 
#define SPECLIST_TAG   waiting_queue
 
#define SPECLIST_TYPE   struct waiting_queue_data
 
#define waiting_queue_list_iterate(list, data)    TYPED_LIST_ITERATE(struct waiting_queue_data, list, data)
 
#define waiting_queue_list_iterate_end   LIST_ITERATE_END
 
#define SPECHASH_TAG   waiting_queue
 
#define SPECHASH_INT_KEY_TYPE
 
#define SPECHASH_IDATA_TYPE   struct waiting_queue_list *
 
#define SPECHASH_IDATA_FREE   waiting_queue_list_destroy
 
#define NEED_UPDATE(city_update, action)
 

Functions

static void update_queue_data_destroy (struct update_queue_data *pdata)
 
static void update_unqueue (void *data)
 
static void update_queue_push (uq_callback_t callback, struct update_queue_data *uq_data)
 
static struct update_queue_dataupdate_queue_data_new (void *data, uq_free_fn_t free_data_func)
 
static struct waiting_queue_datawaiting_queue_data_new (uq_callback_t callback, void *data, uq_free_fn_t free_data_func)
 
static void waiting_queue_data_destroy (struct waiting_queue_data *wq_data)
 
static struct update_queue_datawaiting_queue_data_extract (struct waiting_queue_data *wq_data)
 
void update_queue_init (void)
 
void update_queue_free (void)
 
void update_queue_freeze (void)
 
void update_queue_thaw (void)
 
void update_queue_force_thaw (void)
 
bool update_queue_is_frozen (void)
 
static void waiting_queue_execute_pending_requests (struct waiting_queue_hash *hash, int request_id)
 
void update_queue_processing_started (int request_id)
 
void update_queue_processing_finished (int request_id)
 
void update_queue_add (uq_callback_t callback, void *data)
 
void update_queue_add_full (uq_callback_t callback, void *data, uq_free_fn_t free_data_func)
 
bool update_queue_has_callback (uq_callback_t callback)
 
bool update_queue_has_callback_full (uq_callback_t callback, const void **data, uq_free_fn_t *free_data_func)
 
static void waiting_queue_add_pending_request (struct waiting_queue_hash *hash, int request_id, uq_callback_t callback, void *data, uq_free_fn_t free_data_func)
 
void update_queue_connect_processing_started (int request_id, uq_callback_t callback, void *data)
 
void update_queue_connect_processing_started_full (int request_id, uq_callback_t callback, void *data, uq_free_fn_t free_data_func)
 
void update_queue_connect_processing_finished (int request_id, uq_callback_t callback, void *data)
 
void update_queue_connect_processing_finished_full (int request_id, uq_callback_t callback, void *data, uq_free_fn_t free_data_func)
 
static void set_client_page_callback (void *data)
 
void set_client_page (enum client_pages page)
 
void client_start_server_and_set_page (enum client_pages page)
 
enum client_pages get_client_page (void)
 
bool update_queue_is_switching_page (void)
 
static void menus_update_callback (void *data)
 
void menus_init (void)
 
void menus_update (void)
 
void multipliers_dialog_update (void)
 
static void cities_update_callback (void *data)
 
void popup_city_dialog (struct city *pcity)
 
void refresh_city_dialog (struct city *pcity)
 
void city_report_dialog_update_city (struct city *pcity)
 
void conn_list_dialog_update (void)
 
void players_dialog_update (void)
 
void city_report_dialog_update (void)
 
void science_report_dialog_update (void)
 
void economy_report_dialog_update (void)
 
void units_report_dialog_update (void)
 
void unit_select_dialog_update (void)
 

Variables

static struct update_queue_hashupdate_queue = NULL
 
static struct waiting_queue_hashprocessing_started_waiting_queue = NULL
 
static struct waiting_queue_hashprocessing_finished_waiting_queue = NULL
 
static int update_queue_frozen_level = 0
 
static bool update_queue_has_idle_callback = FALSE
 

Macro Definition Documentation

◆ NEED_UPDATE

#define NEED_UPDATE (   city_update,
  action 
)
Value:
action; \
}
char * incite_cost
Definition comments.c:75

◆ SPECHASH_IDATA_FREE [1/2]

#define SPECHASH_IDATA_FREE   update_queue_data_destroy

Definition at line 61 of file update_queue.c.

◆ SPECHASH_IDATA_FREE [2/2]

#define SPECHASH_IDATA_FREE   waiting_queue_list_destroy

Definition at line 61 of file update_queue.c.

◆ SPECHASH_IDATA_TYPE [1/2]

#define SPECHASH_IDATA_TYPE   struct update_queue_data *

Definition at line 60 of file update_queue.c.

◆ SPECHASH_IDATA_TYPE [2/2]

#define SPECHASH_IDATA_TYPE   struct waiting_queue_list *

Definition at line 60 of file update_queue.c.

◆ SPECHASH_IKEY_TYPE

#define SPECHASH_IKEY_TYPE   uq_callback_t

Definition at line 59 of file update_queue.c.

◆ SPECHASH_INT_KEY_TYPE

#define SPECHASH_INT_KEY_TYPE

Definition at line 86 of file update_queue.c.

◆ SPECHASH_TAG [1/2]

#define SPECHASH_TAG   update_queue

Definition at line 58 of file update_queue.c.

◆ SPECHASH_TAG [2/2]

#define SPECHASH_TAG   waiting_queue

Definition at line 58 of file update_queue.c.

◆ SPECLIST_TAG

#define SPECLIST_TAG   waiting_queue

Definition at line 77 of file update_queue.c.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct waiting_queue_data

Definition at line 78 of file update_queue.c.

◆ update_queue_hash_iterate

#define update_queue_hash_iterate (   hash,
  callback,
  uq_data 
)
Value:
hash, callback, uq_data)
static GHashTable * hash
Definition wldlg.c:322
#define TYPED_HASH_ITERATE(TYPE_key, TYPE_data, ARG_ht, NAME_key, NAME_data)
Definition spechash.h:726
void(* uq_callback_t)(void *data)

Definition at line 63 of file update_queue.c.

◆ update_queue_hash_iterate_end

#define update_queue_hash_iterate_end   HASH_ITERATE_END

Definition at line 66 of file update_queue.c.

◆ waiting_queue_list_iterate

#define waiting_queue_list_iterate (   list,
  data 
)     TYPED_LIST_ITERATE(struct waiting_queue_data, list, data)

Definition at line 80 of file update_queue.c.

◆ waiting_queue_list_iterate_end

#define waiting_queue_list_iterate_end   LIST_ITERATE_END

Definition at line 82 of file update_queue.c.

Function Documentation

◆ cities_update_callback()

static void cities_update_callback ( void data)
static

Update cities gui.

Definition at line 580 of file update_queue.c.

Referenced by city_report_dialog_update_city(), popup_city_dialog(), and refresh_city_dialog().

◆ city_report_dialog_update()

void city_report_dialog_update ( void  )

◆ city_report_dialog_update_city()

void city_report_dialog_update_city ( struct city pcity)

Request the city to be updated in the city report.

Definition at line 641 of file update_queue.c.

Referenced by city_packet_common(), cma_release_city(), handle_city_update_counters(), popup_cma_from_city_report_callback(), and real_city_dialog_refresh().

◆ client_start_server_and_set_page()

void client_start_server_and_set_page ( enum client_pages  page)

Start server and then, set the client page.

Definition at line 506 of file update_queue.c.

Referenced by load_saved_game_callback(), start_scenario_callback(), and fc_client::switch_page().

◆ conn_list_dialog_update()

void conn_list_dialog_update ( void  )

◆ economy_report_dialog_update()

void economy_report_dialog_update ( void  )

Update the economy report.

Definition at line 682 of file update_queue.c.

Referenced by handle_city_info(), handle_player_info(), handle_unit_packet_common(), handle_unit_remove(), and real_city_dialog_refresh().

◆ get_client_page()

enum client_pages get_client_page ( void  )

◆ menus_init()

void menus_init ( void  )

Request the menus to be initialized and updated.

Definition at line 554 of file update_queue.c.

Referenced by enable_menus(), set_client_state(), tilespec_reread_callback(), and tilespec_reread_frozen_refresh().

◆ menus_update()

void menus_update ( void  )

◆ menus_update_callback()

static void menus_update_callback ( void data)
static

Update the menus.

Definition at line 543 of file update_queue.c.

Referenced by menus_init(), and menus_update().

◆ multipliers_dialog_update()

void multipliers_dialog_update ( void  )

Update multipliers/policy dialog.

Definition at line 572 of file update_queue.c.

Referenced by handle_player_info().

◆ players_dialog_update()

void players_dialog_update ( void  )

◆ popup_city_dialog()

void popup_city_dialog ( struct city pcity)

◆ refresh_city_dialog()

void refresh_city_dialog ( struct city pcity)

◆ science_report_dialog_update()

void science_report_dialog_update ( void  )

Update the science report.

Definition at line 674 of file update_queue.c.

Referenced by handle_city_info(), handle_player_info(), and handle_research_info().

◆ set_client_page()

void set_client_page ( enum client_pages  page)

◆ set_client_page_callback()

static void set_client_page_callback ( void data)
static

Set the client page.

Definition at line 476 of file update_queue.c.

Referenced by client_start_server_and_set_page(), get_client_page(), set_client_page(), and update_queue_is_switching_page().

◆ unit_select_dialog_update()

void unit_select_dialog_update ( void  )

Update the units report.

Definition at line 698 of file update_queue.c.

Referenced by handle_unit_packet_common().

◆ units_report_dialog_update()

void units_report_dialog_update ( void  )

Update the units report.

Definition at line 690 of file update_queue.c.

Referenced by handle_city_info(), handle_player_info(), handle_unit_packet_common(), and handle_unit_remove().

◆ update_queue_add()

void update_queue_add ( uq_callback_t  callback,
void data 
)

◆ update_queue_add_full()

void update_queue_add_full ( uq_callback_t  callback,
void data,
uq_free_fn_t  free_data_func 
)

Add a callback to the update queue. NB: you can only set a callback once. Setting a callback twice will overwrite the previous.

Definition at line 356 of file update_queue.c.

◆ update_queue_connect_processing_finished()

void update_queue_connect_processing_finished ( int  request_id,
uq_callback_t  callback,
void data 
)

Connects the callback to the end of the processing (in server side) of the request.

Definition at line 450 of file update_queue.c.

Referenced by client_start_server_and_set_page(), and client_take_player().

◆ update_queue_connect_processing_finished_full()

void update_queue_connect_processing_finished_full ( int  request_id,
uq_callback_t  callback,
void data,
uq_free_fn_t  free_data_func 
)

Connects the callback to the end of the processing (in server side) of the request.

Definition at line 462 of file update_queue.c.

Referenced by do_disband_alternative().

◆ update_queue_connect_processing_started()

void update_queue_connect_processing_started ( int  request_id,
uq_callback_t  callback,
void data 
)

Connects the callback to the start of the processing (in server side) of the request.

Definition at line 423 of file update_queue.c.

◆ update_queue_connect_processing_started_full()

void update_queue_connect_processing_started_full ( int  request_id,
uq_callback_t  callback,
void data,
uq_free_fn_t  free_data_func 
)

Connects the callback to the start of the processing (in server side) of the request.

Definition at line 435 of file update_queue.c.

◆ update_queue_data_destroy()

static void update_queue_data_destroy ( struct update_queue_data uq_data)
static

Free a update queue data.

Definition at line 117 of file update_queue.c.

Referenced by waiting_queue_data_destroy().

◆ update_queue_data_new()

static struct update_queue_data * update_queue_data_new ( void data,
uq_free_fn_t  free_data_func 
)
inlinestatic

Create a new update queue data.

Definition at line 105 of file update_queue.c.

Referenced by update_queue_add(), update_queue_add_full(), and waiting_queue_data_new().

◆ update_queue_force_thaw()

void update_queue_force_thaw ( void  )

Free the update queue.

Definition at line 242 of file update_queue.c.

◆ update_queue_free()

void update_queue_free ( void  )

Free the update queue.

Definition at line 190 of file update_queue.c.

Referenced by at_exit().

◆ update_queue_freeze()

void update_queue_freeze ( void  )

Freezes the update queue.

Definition at line 216 of file update_queue.c.

◆ update_queue_has_callback()

bool update_queue_has_callback ( uq_callback_t  callback)

Returns whether this callback is listed in the update queue.

Definition at line 367 of file update_queue.c.

Referenced by menus_update(), and update_queue_is_switching_page().

◆ update_queue_has_callback_full()

bool update_queue_has_callback_full ( uq_callback_t  callback,
const void **  data,
uq_free_fn_t free_data_func 
)

Returns whether this callback is listed in the update queue and get the its data and free function. 'data' and 'free_data_func' can be NULL.

Definition at line 378 of file update_queue.c.

Referenced by get_client_page().

◆ update_queue_init()

void update_queue_init ( void  )

Initialize the update queue.

Definition at line 169 of file update_queue.c.

Referenced by client_game_free(), client_game_init(), and client_main().

◆ update_queue_is_frozen()

bool update_queue_is_frozen ( void  )

Free the update queue.

Definition at line 252 of file update_queue.c.

Referenced by update_queue_force_thaw(), update_queue_push(), and update_unqueue().

◆ update_queue_is_switching_page()

bool update_queue_is_switching_page ( void  )

Returns whether there's page switching already in progress.

Definition at line 535 of file update_queue.c.

Referenced by set_turn_done_button_state().

◆ update_queue_processing_finished()

void update_queue_processing_finished ( int  request_id)

Moves the instances waiting to the request_id to the callback queue.

Definition at line 288 of file update_queue.c.

Referenced by handle_processing_finished().

◆ update_queue_processing_started()

void update_queue_processing_started ( int  request_id)

Moves the instances waiting to the request_id to the callback queue.

Definition at line 279 of file update_queue.c.

Referenced by handle_processing_started().

◆ update_queue_push()

static void update_queue_push ( uq_callback_t  callback,
struct update_queue_data uq_data 
)
inlinestatic

Add a callback to the update queue. NB: you can only set a callback once. Setting a callback twice will overwrite the previous.

Definition at line 329 of file update_queue.c.

Referenced by update_queue_add(), update_queue_add_full(), and waiting_queue_execute_pending_requests().

◆ update_queue_thaw()

void update_queue_thaw ( void  )

Free the update queue.

Definition at line 224 of file update_queue.c.

Referenced by update_queue_force_thaw().

◆ update_unqueue()

static void update_unqueue ( void data)
static

Unqueue all updates.

Definition at line 297 of file update_queue.c.

Referenced by update_queue_push(), and update_queue_thaw().

◆ waiting_queue_add_pending_request()

static void waiting_queue_add_pending_request ( struct waiting_queue_hash hash,
int  request_id,
uq_callback_t  callback,
void data,
uq_free_fn_t  free_data_func 
)
inlinestatic

◆ waiting_queue_data_destroy()

static void waiting_queue_data_destroy ( struct waiting_queue_data wq_data)
static

Free a waiting queue data.

Definition at line 143 of file update_queue.c.

Referenced by waiting_queue_add_pending_request().

◆ waiting_queue_data_extract()

static struct update_queue_data * waiting_queue_data_extract ( struct waiting_queue_data wq_data)
inlinestatic

Extract the update_queue_data from the waiting queue data.

Definition at line 157 of file update_queue.c.

Referenced by waiting_queue_execute_pending_requests().

◆ waiting_queue_data_new()

static struct waiting_queue_data * waiting_queue_data_new ( uq_callback_t  callback,
void data,
uq_free_fn_t  free_data_func 
)
inlinestatic

Create a new waiting queue data.

Definition at line 130 of file update_queue.c.

Referenced by waiting_queue_add_pending_request().

◆ waiting_queue_execute_pending_requests()

static void waiting_queue_execute_pending_requests ( struct waiting_queue_hash hash,
int  request_id 
)
inlinestatic

Moves the instances waiting to the request_id to the callback queue.

Definition at line 261 of file update_queue.c.

Referenced by update_queue_processing_finished(), and update_queue_processing_started().

Variable Documentation

◆ processing_finished_waiting_queue

struct waiting_queue_hash* processing_finished_waiting_queue = NULL
static

◆ processing_started_waiting_queue

struct waiting_queue_hash* processing_started_waiting_queue = NULL
static

◆ update_queue

struct update_queue_hash* update_queue = NULL
static

◆ update_queue_frozen_level

int update_queue_frozen_level = 0
static

◆ update_queue_has_idle_callback

bool update_queue_has_idle_callback = FALSE
static