Thread.c File Reference

Threading related functions. More...

#include "Thread.h"
#include "StackTrace.h"
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <limits.h>
#include <stdlib.h>
#include "OsWrapper.h"
Include dependency graph for Thread.c:

Functions

thread_type Thread_start (thread_fn fn, void *parameter)
 Start a new thread.
mutex_type Thread_create_mutex (void)
 Create a new mutex.
int Thread_lock_mutex (mutex_type mutex)
 Lock a mutex which has alrea.
int Thread_unlock_mutex (mutex_type mutex)
 Unlock a mutex which has already been locked.
void Thread_destroy_mutex (mutex_type mutex)
 Destroy a mutex which has already been created.
thread_id_type Thread_getid (void)
 Get the thread id of the thread from which this function is called.
sem_type Thread_create_sem (void)
 Create a new semaphore.
int Thread_wait_sem (sem_type sem, int timeout)
 Wait for a semaphore to be posted, or timeout.
int Thread_check_sem (sem_type sem)
 Check to see if a semaphore has been posted, without waiting.
int Thread_post_sem (sem_type sem)
 Post a semaphore.
int Thread_destroy_sem (sem_type sem)
 Destroy a semaphore which has already been created.
cond_type Thread_create_cond (void)
 Create a new condition variable.
int Thread_signal_cond (cond_type condvar)
 Signal a condition variable.
int Thread_wait_cond (cond_type condvar, int timeout)
 Wait with a timeout (seconds) for condition variable.
int Thread_destroy_cond (cond_type condvar)
 Destroy a condition variable.

Detailed Description

Threading related functions.

Used to create platform independent threading functions


Function Documentation

int Thread_check_sem ( sem_type  sem  ) 

Check to see if a semaphore has been posted, without waiting.

Parameters:
sem the semaphore
Returns:
0 (false) or 1 (true)
cond_type Thread_create_cond ( void   ) 

Create a new condition variable.

Returns:
the condition variable struct
mutex_type Thread_create_mutex ( void   ) 

Create a new mutex.

Returns:
the new mutex
sem_type Thread_create_sem ( void   ) 

Create a new semaphore.

Returns:
the new condition variable
int Thread_destroy_cond ( cond_type  condvar  ) 

Destroy a condition variable.

Returns:
completion code
void Thread_destroy_mutex ( mutex_type  mutex  ) 

Destroy a mutex which has already been created.

Parameters:
mutex the mutex
int Thread_destroy_sem ( sem_type  sem  ) 

Destroy a semaphore which has already been created.

Parameters:
sem the semaphore
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
int Thread_lock_mutex ( mutex_type  mutex  ) 

Lock a mutex which has alrea.

Returns:
completion code, 0 is success
int Thread_post_sem ( sem_type  sem  ) 

Post a semaphore.

Parameters:
sem the semaphore
Returns:
completion code
int Thread_signal_cond ( cond_type  condvar  ) 

Signal a condition variable.

Returns:
completion code
thread_type Thread_start ( thread_fn  fn,
void *  parameter 
)

Start a new thread.

Parameters:
fn the function to run, must be of the correct signature
parameter pointer to the function parameter, can be NULL
Returns:
the new thread
int Thread_unlock_mutex ( mutex_type  mutex  ) 

Unlock a mutex which has already been locked.

Parameters:
mutex the mutex
Returns:
completion code, 0 is success
int Thread_wait_cond ( cond_type  condvar,
int  timeout 
)

Wait with a timeout (seconds) for condition variable.

Returns:
completion code
int Thread_wait_sem ( sem_type  sem,
int  timeout 
)

Wait for a semaphore to be posted, or timeout.

Parameters:
sem the semaphore
timeout the maximum time to wait, in milliseconds
Returns:
completion code
 All Data Structures Files Functions Variables Typedefs Defines

Generated on 2 Jun 2018 for MQTT C Client Libraries Internals by  doxygen 1.6.1