Freeciv-3.4
Loading...
Searching...
No Matches
Data Structures | Functions | Variables
fcthread.c File Reference
#include "log.h"
#include "mem.h"
#include "support.h"
#include "fcthread.h"

Go to the source code of this file.

Data Structures

struct  fc_thread_wrap_data
 

Functions

bool register_at_thread_exit_callback (at_thread_exit_cb *cb)
 
static void at_thread_exit (void)
 
static int fc_thread_wrapper (void *arg)
 
int fc_thread_start (fc_thread *thread, void(*function)(void *arg), void *arg)
 
void fc_thread_wait (fc_thread *thread)
 
fc_thread_id fc_thread_self (void)
 
bool fc_threads_equal (fc_thread_id thr1, fc_thread_id thr2)
 
void fc_mutex_init (fc_mutex *mutex)
 
void fc_mutex_destroy (fc_mutex *mutex)
 
void fc_mutex_allocate (fc_mutex *mutex)
 
void fc_mutex_release (fc_mutex *mutex)
 
void fc_thread_cond_init (fc_thread_cond *cond)
 
void fc_thread_cond_destroy (fc_thread_cond *cond)
 
void fc_thread_cond_wait (fc_thread_cond *cond, fc_mutex *mutex)
 
void fc_thread_cond_signal (fc_thread_cond *cond)
 
bool has_thread_cond_impl (void)
 

Variables

static at_thread_exit_cbate_cb = nullptr
 

Function Documentation

◆ at_thread_exit()

static void at_thread_exit ( void  )
static

Called at thread exit by all the thread implementations.

Definition at line 49 of file fcthread.c.

Referenced by fc_thread_wrapper().

◆ fc_mutex_allocate()

void fc_mutex_allocate ( fc_mutex mutex)

◆ fc_mutex_destroy()

void fc_mutex_destroy ( fc_mutex mutex)

◆ fc_mutex_init()

void fc_mutex_init ( fc_mutex mutex)

◆ fc_mutex_release()

void fc_mutex_release ( fc_mutex mutex)

◆ fc_thread_cond_destroy()

void fc_thread_cond_destroy ( fc_thread_cond cond)

Destroy condition

Dummy fc_thread_cond_destroy()

Definition at line 168 of file fcthread.c.

Referenced by texai_control_lost().

◆ fc_thread_cond_init()

void fc_thread_cond_init ( fc_thread_cond cond)

Initialize condition

Dummy fc_thread_cond_init()

Definition at line 160 of file fcthread.c.

Referenced by texai_control_gained().

◆ fc_thread_cond_signal()

void fc_thread_cond_signal ( fc_thread_cond cond)

Signal other thread to continue on fulfilled condition

Dummy fc_thread_cond_signal()

Definition at line 184 of file fcthread.c.

Referenced by texai_msg_to_thr().

◆ fc_thread_cond_wait()

void fc_thread_cond_wait ( fc_thread_cond cond,
fc_mutex mutex 
)

Wait for condition to be fulfilled

Dummy fc_thread_cond_wait()

Definition at line 176 of file fcthread.c.

Referenced by texai_thread_start().

◆ fc_thread_self()

fc_thread_id fc_thread_self ( void  )

Get thread id

Definition at line 112 of file fcthread.c.

◆ fc_thread_start()

int fc_thread_start ( fc_thread thread,
void(*)(void *arg)  function,
void arg 
)

Create new thread

Definition at line 83 of file fcthread.c.

Referenced by save_game(), server_scan_begin(), and texai_control_gained().

◆ fc_thread_wait()

void fc_thread_wait ( fc_thread thread)

Wait for thread to finish

Definition at line 102 of file fcthread.c.

Referenced by save_game(), save_system_close(), send_server_info_to_metaserver(), server_scan_finish(), and texai_control_lost().

◆ fc_thread_wrapper()

static int fc_thread_wrapper ( void arg)
static

Wrapper which fingerprint matches one required by pthread_create(). Calls function which matches fingerprint required by fc_thread_start()

Definition at line 67 of file fcthread.c.

Referenced by fc_thread_start().

◆ fc_threads_equal()

bool fc_threads_equal ( fc_thread_id  thr1,
fc_thread_id  thr2 
)

Tell if two threads are the same

Definition at line 120 of file fcthread.c.

◆ has_thread_cond_impl()

bool has_thread_cond_impl ( void  )

Has freeciv thread condition variable implementation

Definition at line 490 of file fcthread.c.

Referenced by fc_ai_tex_setup().

◆ register_at_thread_exit_callback()

bool register_at_thread_exit_callback ( at_thread_exit_cb cb)

Register callback to be called whenever a thread finishes. This can be called only once. Latter calls will cause an error message and return FALSE.

Definition at line 32 of file fcthread.c.

Variable Documentation

◆ ate_cb

at_thread_exit_cb* ate_cb = nullptr
static

Definition at line 25 of file fcthread.c.

Referenced by at_thread_exit(), and register_at_thread_exit_callback().