Classes | Macros | Typedefs | Functions
Thread.h File Reference
#include "MQTTExportDeclarations.h"
#include "MQTTClient.h"
#include "mutex_type.h"
#include <pthread.h>
#include <semaphore.h>
Include dependency graph for Thread.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  cond_type_struct
 

Macros

#define thread_id_type   pthread_t
 
#define thread_return_type   void*
 
#define thread_type   pthread_t
 

Typedefs

typedef cond_type_structcond_type
 
typedef sem_t * sem_type
 
typedef thread_return_type(* thread_fn) (void *)
 

Functions

int Thread_check_sem (sem_type sem)
 
cond_type Thread_create_cond (int *)
 
LIBMQTT_API mutex_type Thread_create_mutex (int *)
 
sem_type Thread_create_sem (int *)
 
int Thread_destroy_cond (cond_type)
 
int Thread_destroy_mutex (mutex_type)
 
int Thread_destroy_sem (sem_type sem)
 
LIBMQTT_API thread_id_type Thread_getid ()
 
LIBMQTT_API int Thread_lock_mutex (mutex_type)
 
int Thread_post_sem (sem_type sem)
 
int Thread_signal_cond (cond_type)
 
LIBMQTT_API thread_type Thread_start (thread_fn, void *)
 
LIBMQTT_API int Thread_unlock_mutex (mutex_type)
 
int Thread_wait_cond (cond_type condvar, int timeout)
 
int Thread_wait_sem (sem_type sem, int timeout)
 

Macro Definition Documentation

#define thread_id_type   pthread_t

Definition at line 43 of file Thread.h.

#define thread_return_type   void*

Definition at line 44 of file Thread.h.

#define thread_type   pthread_t

Definition at line 42 of file Thread.h.

Typedef Documentation

Definition at line 47 of file Thread.h.

typedef sem_t* sem_type

Definition at line 53 of file Thread.h.

typedef thread_return_type(* thread_fn) (void *)

Definition at line 45 of file Thread.h.

Function Documentation

int Thread_check_sem ( sem_type  sem)

Check to see if a semaphore has been posted, without waiting The semaphore will be unchanged, if the return value is false. The semaphore will have been decremented, if the return value is true.

Parameters
semthe semaphore
Returns
0 (false) or 1 (true)

Definition at line 292 of file Thread.c.

cond_type Thread_create_cond ( int *  rc)

Create a new condition variable

Returns
the condition variable struct

Definition at line 365 of file Thread.c.

LIBMQTT_API mutex_type Thread_create_mutex ( int *  rc)

Create a new mutex

Returns
the new mutex

Definition at line 88 of file Thread.c.

sem_type Thread_create_sem ( int *  rc)

Create a new semaphore

Returns
the new condition variable

Definition at line 190 of file Thread.c.

int Thread_destroy_cond ( cond_type  condvar)

Destroy a condition variable

Returns
completion code

Definition at line 444 of file Thread.c.

int Thread_destroy_mutex ( mutex_type  mutex)

Destroy a mutex which has already been created

Parameters
mutexthe mutex

Definition at line 156 of file Thread.c.

int Thread_destroy_sem ( sem_type  sem)

Destroy a semaphore which has already been created

Parameters
semthe semaphore

Definition at line 341 of file Thread.c.

LIBMQTT_API thread_id_type Thread_getid ( void  )

Get the thread id of the thread from which this function is called

Returns
thread id, type varying according to OS

Definition at line 176 of file Thread.c.

LIBMQTT_API int Thread_lock_mutex ( mutex_type  mutex)

Lock a mutex which has alrea

Returns
completion code, 0 is success

Definition at line 112 of file Thread.c.

int Thread_post_sem ( sem_type  sem)

Post a semaphore

Parameters
semthe semaphore
Returns
0 on success

Definition at line 313 of file Thread.c.

int Thread_signal_cond ( cond_type  condvar)

Signal a condition variable

Returns
completion code

Definition at line 399 of file Thread.c.

LIBMQTT_API thread_type Thread_start ( thread_fn  fn,
void *  parameter 
)

Start a new thread

Parameters
fnthe function to run, must be of the correct signature
parameterpointer to the function parameter, can be NULL
Returns
the new thread

Definition at line 60 of file Thread.c.

LIBMQTT_API int Thread_unlock_mutex ( mutex_type  mutex)

Unlock a mutex which has already been locked

Parameters
mutexthe mutex
Returns
completion code, 0 is success

Definition at line 133 of file Thread.c.

int Thread_wait_cond ( cond_type  condvar,
int  timeout 
)

Wait with a timeout (seconds) for condition variable

Returns
0 for success, ETIMEDOUT otherwise

Definition at line 416 of file Thread.c.

int Thread_wait_sem ( sem_type  sem,
int  timeout 
)

Wait for a semaphore to be posted, or timeout.

Parameters
semthe semaphore
timeoutthe maximum time to wait, in milliseconds
Returns
completion code

Definition at line 230 of file Thread.c.



plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:49