MQTT C Client Libraries Internals
Loading...
Searching...
No Matches
Thread.c File Reference

Threading related functions. More...

#include "Thread.h"
#include "Log.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:

Macros

#define NSEC_PER_SEC   1000000000L

Functions

void Paho_thread_start (thread_fn fn, void *parameter)
 Start a new thread.
int Thread_set_name (const char *thread_name)
thread_id_type Paho_thread_getid (void)
 Get the thread id of the thread from which this function is called.
struct timespec Thread_time_from_now (int ms)
mutex_type Paho_thread_create_mutex (int *rc)
 Create a new mutex.
int Paho_thread_lock_mutex (mutex_type mutex)
 Lock a mutex which has alrea.
int Paho_thread_unlock_mutex (mutex_type mutex)
 Unlock a mutex which has already been locked.
int Paho_thread_destroy_mutex (mutex_type mutex)
 Destroy a mutex which has already been created.
evt_type Thread_create_evt (int *rc)
 Create a new event.
int Thread_signal_evt (evt_type evt)
 Signal an event.
int Thread_wait_evt (evt_type evt, int timeout_ms)
 Wait with a timeout (ms) for the event to become signaled.
int Thread_destroy_evt (evt_type evt)
 Destroy an event object.

Detailed Description

Threading related functions.

Used to create platform independent threading functions

Function Documentation

◆ Paho_thread_create_mutex()

mutex_type Paho_thread_create_mutex ( int * rc)

Create a new mutex.

Parameters
rcreturn code: 0 for success, negative otherwise
Returns
the new mutex

◆ Paho_thread_destroy_mutex()

int Paho_thread_destroy_mutex ( mutex_type mutex)

Destroy a mutex which has already been created.

Parameters
mutexthe mutex

◆ Paho_thread_getid()

thread_id_type Paho_thread_getid ( void )

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

Returns
thread id, type varying according to OS

◆ Paho_thread_lock_mutex()

int Paho_thread_lock_mutex ( mutex_type mutex)

Lock a mutex which has alrea.

Returns
completion code, 0 is success

◆ Paho_thread_start()

void Paho_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

◆ Paho_thread_unlock_mutex()

int Paho_thread_unlock_mutex ( mutex_type mutex)

Unlock a mutex which has already been locked.

Parameters
mutexthe mutex
Returns
completion code, 0 is success

◆ Thread_create_evt()

evt_type Thread_create_evt ( int * rc)

Create a new event.

Returns
the event struct

◆ Thread_destroy_evt()

int Thread_destroy_evt ( evt_type evt)

Destroy an event object.

Returns
completion code, 0 for success

◆ Thread_signal_evt()

int Thread_signal_evt ( evt_type evt)

Signal an event.

Returns
completion code, 0 is success

◆ Thread_wait_evt()

int Thread_wait_evt ( evt_type evt,
int timeout_ms )

Wait with a timeout (ms) for the event to become signaled.

Returns
The completion code: 0 for success, ETIMEDOUT otherwise