Data Structures | Macros | Typedefs | Functions
compat_mutex.h File Reference
#include "orconfig.h"
#include "lib/cc/torint.h"
#include "lib/malloc/malloc.h"

Go to the source code of this file.

Data Structures

struct  tor_mutex_t


#define tor_mutex_free(m)   FREE_AND_NULL(tor_mutex_t, tor_mutex_free_, (m))


typedef struct tor_mutex_t tor_mutex_t


tor_mutex_ttor_mutex_new (void)
tor_mutex_ttor_mutex_new_nonrecursive (void)
void tor_mutex_init (tor_mutex_t *m)
void tor_mutex_init_nonrecursive (tor_mutex_t *m)
void tor_mutex_acquire (tor_mutex_t *m)
void tor_mutex_release (tor_mutex_t *m)
void tor_mutex_free_ (tor_mutex_t *m)
void tor_mutex_uninit (tor_mutex_t *m)
void tor_locking_init (void)

Detailed Description

Header for compat_mutex.c.

Definition in file compat_mutex.h.

Typedef Documentation

◆ tor_mutex_t

typedef struct tor_mutex_t tor_mutex_t

A generic lock structure for multithreaded builds.

Function Documentation

◆ tor_mutex_acquire()

void tor_mutex_acquire ( tor_mutex_t m)

◆ tor_mutex_free_()

void tor_mutex_free_ ( tor_mutex_t m)

Release all storage and system resources held by m.

Definition at line 34 of file compat_mutex.c.

References tor_free, and tor_mutex_uninit().

◆ tor_mutex_init()

void tor_mutex_init ( tor_mutex_t mutex)

Initialize mutex so it can be locked. Every mutex must be set up with tor_mutex_init() or tor_mutex_new(); not both.

Definition at line 35 of file compat_mutex_pthreads.c.

Referenced by init_logging().

◆ tor_mutex_init_nonrecursive()

void tor_mutex_init_nonrecursive ( tor_mutex_t mutex)

As tor_mutex_init, but initialize a mutex suitable that may be non-recursive, if the OS supports that.

Definition at line 50 of file compat_mutex_pthreads.c.

Referenced by atomic_counter_init().

◆ tor_mutex_new()

tor_mutex_t* tor_mutex_new ( void  )

Return a newly allocated, ready-for-use mutex.

Definition at line 17 of file compat_mutex.c.

Referenced by tor_gmtime_r_msg(), and tor_localtime_r_msg().

◆ tor_mutex_new_nonrecursive()

tor_mutex_t* tor_mutex_new_nonrecursive ( void  )

Return a newly allocated, ready-for-use mutex. This one might be non-recursive, if that's faster.

Definition at line 26 of file compat_mutex.c.

◆ tor_mutex_release()

void tor_mutex_release ( tor_mutex_t m)

◆ tor_mutex_uninit()

void tor_mutex_uninit ( tor_mutex_t m)

Clean up the mutex m so that it no longer uses any system resources. Does not free m. This function must only be called on mutexes from tor_mutex_init().

Definition at line 93 of file compat_mutex_pthreads.c.

Referenced by atomic_counter_destroy(), and tor_mutex_free_().