Nigel Rantor / azure_c_shared_utility

Fork of azure_c_shared_utility by Azure IoT

Embed: (wiki syntax)

« Back to documentation index

threadapi.h File Reference

threadapi.h File Reference

This module implements support for creating new threads, terminating threads and sleeping threads. More...

Go to the source code of this file.

Functions

 DEFINE_ENUM (THREADAPI_RESULT, THREADAPI_RESULT_VALUES)
 Enumeration specifying the possible return values for the APIs in this module.
 MOCKABLE_FUNCTION (, THREADAPI_RESULT, ThreadAPI_Create, THREAD_HANDLE *, threadHandle, THREAD_START_FUNC, func, void *, arg)
 Creates a thread with the entry point specified by the func argument.
 MOCKABLE_FUNCTION (, THREADAPI_RESULT, ThreadAPI_Join, THREAD_HANDLE, threadHandle, int *, res)
 Blocks the calling thread by waiting on the thread identified by the threadHandle argument to complete.
 MOCKABLE_FUNCTION (, void, ThreadAPI_Exit, int, res)
 This function is called by a thread when the thread exits.
 MOCKABLE_FUNCTION (, void, ThreadAPI_Sleep, unsigned int, milliseconds)
 Sleeps the current thread for the given number of milliseconds.

Detailed Description

This module implements support for creating new threads, terminating threads and sleeping threads.

Definition in file threadapi.h.


Function Documentation

DEFINE_ENUM ( THREADAPI_RESULT  ,
THREADAPI_RESULT_VALUES   
)

Enumeration specifying the possible return values for the APIs in this module.

MOCKABLE_FUNCTION ( void  ,
ThreadAPI_Sleep  ,
unsigned  int,
milliseconds   
)

Sleeps the current thread for the given number of milliseconds.

Parameters:
millisecondsThe number of milliseconds to sleep.
MOCKABLE_FUNCTION ( void  ,
ThreadAPI_Exit  ,
int  ,
res   
)

This function is called by a thread when the thread exits.

Parameters:
resAn integer that represents the exit status of the thread.

This function is called by a thread when the thread exits in order to return a result value to the caller of the ThreadAPI_Join function. The res value must be copied into the res out argument passed to the ThreadAPI_Join function.

MOCKABLE_FUNCTION ( THREADAPI_RESULT  ,
ThreadAPI_Join  ,
THREAD_HANDLE  ,
threadHandle  ,
int *  ,
res   
)

Blocks the calling thread by waiting on the thread identified by the threadHandle argument to complete.

Parameters:
threadHandleThe handle of the thread to wait for completion.
resThe result returned by the thread which is passed to the ThreadAPI_Exit function.

When the threadHandle thread completes, all resources associated with the thread must be released and the thread handle will no longer be valid.

Returns:
THREADAPI_OK if the API call is successful or an error code in case it fails.
MOCKABLE_FUNCTION ( THREADAPI_RESULT  ,
ThreadAPI_Create  ,
THREAD_HANDLE *  ,
threadHandle  ,
THREAD_START_FUNC  ,
func  ,
void *  ,
arg   
)

Creates a thread with the entry point specified by the func argument.

Parameters:
threadHandleThe handle to the new thread is returned in this pointer.
funcA function pointer that indicates the entry point to the new thread.
argA void pointer that must be passed to the function pointed to by func.
Returns:
THREADAPI_OK if the API call is successful or an error code in case it fails.