ThingWorx Edge C SDK > Porting to Another Platform > Native Threads
  
Native Threads
With the built-in tasker, the C SDK has does not depend on a threading OS. However, if one is present, there are advantages to using native threads. Therefore, the C SDK provides a wrapper layer around native threads that maps tasks as defined for the built-in tasker to native threads. Porting the wrapper to a native threading model is straightforward and requires the implementation of only a few functions. These functions are defined in the file src/porting/twThreads.h.
The twThread structure follows:
typedef struct twThread {
TW_THREAD_ID id;
twTaskFunction func;
uint32_t rate;
char isRunning;
char isPaused;
char shutdownRequested;
char hasStopped;
void * opaquePtr;
}twThread;
The following table lists and describes the functions available for threads. For details, refer to the Doxygen documentation provided with the SDK.
Function
Description
twThread_Create
Create a new thread and optionally start it.
twThread_Delete
Stop a thread and free up the thread structure memory.
twThread_Start
Start a thread.
twThread_Stop
Stop a thread and optionally specify a number of milliseconds to wait for the thread to exit before forcefully killingit.
twThread_Pause
Pause the execution of a thread.
twThread_Resume
Resume the execution of a thread.
twThread_IsRunning
Check if a specified thread is running.
twThread_IsPaused
Check if a specified thread is paused.
twThread_IsStopped
Check if a specified thread is stopped.