ThingWorx C SDK
twThreads.h
Go to the documentation of this file.
1 /***************************************
2  * Copyright (C) 2015 ThingWorx Inc. *
3  ***************************************/
4 
10 #ifndef TW_THREADS_H
11 #define TW_THREADS_H
12 
13 #include <stdint.h>
14 #include <stdlib.h>
15 #include <time.h>
16 
17 #include "twDefinitions.h"
18 #include "twOSPort.h"
19 #include "twTasker.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
32 typedef struct twThread {
33  TW_THREAD_ID id;
35  uint32_t rate;
36  char isRunning;
37  char isPaused;
39  char hasStopped;
40  void * opaquePtr;
41 } twThread;
42 
57 twThread * twThread_Create(twTaskFunction func, uint32_t rate, void * opaquePtr, char autoStart);
58 
70 void twThread_Delete(void * t);
71 
80 int twThread_Start(twThread * t);
81 
95 int twThread_Stop(twThread * t, int32_t waitTime);
96 
105 int twThread_Pause(twThread * t);
106 
115 int twThread_Resume(twThread * t);
116 
124 char twThread_IsRunning(twThread * t);
125 
133 char twThread_IsPaused(twThread * t);
134 
142 char twThread_IsStopped(twThread * t);
143 
151 TW_THREAD_ID twThread_GetThreadId(twThread * t);
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 #endif
int twThread_Stop(twThread *t, int32_t waitTime)
Stops a twThread.
Definition: twPThreads.c:74
char twThread_IsPaused(twThread *t)
Checks if a twThread is paused via twThread::isPaused of t.
Definition: twPThreads.c:101
TW_THREAD_ID id
Definition: twThreads.h:33
twTaskFunction func
Definition: twThreads.h:34
int twThread_Resume(twThread *t)
Resumes a twThread.
Definition: twPThreads.c:91
int twThread_Start(twThread *t)
Starts a twThread.
Definition: twPThreads.c:68
uint32_t rate
Definition: twThreads.h:35
char twThread_IsStopped(twThread *t)
Checks if a twThread has stopped via twThread::hasStopped of t.
Definition: twPThreads.c:105
struct twThread twThread
twThread structure definition.
Wrappers for OS-specific functionality.
void * opaquePtr
Definition: twThreads.h:40
twThread structure definition.
Definition: twThreads.h:32
char isPaused
Definition: twThreads.h:37
char hasStopped
Definition: twThreads.h:39
twThread * twThread_Create(twTaskFunction func, uint32_t rate, void *opaquePtr, char autoStart)
Creates a new twThread.
Definition: twPThreads.c:39
Common definitions for C SDK.
TW_THREAD_ID twThread_GetThreadId(twThread *t)
Gets the id of a thread via twThread::id of t.
Definition: twPThreads.c:109
void twThread_Delete(void *t)
Frees all memory associated with a twThread and all of its owned substructures.
Definition: twPThreads.c:61
void(* twTaskFunction)(uint64_t sys_msecs, void *params)
Function signature of a task called in round robin fashion.
Definition: twTasker.h:32
int twThread_Pause(twThread *t)
Pauses a twThread.
Definition: twPThreads.c:85
char isRunning
Definition: twThreads.h:36
Simple ThingWorx Tasker.
char twThread_IsRunning(twThread *t)
Checks if a twThread is running via twThread::isRunning of t.
Definition: twPThreads.c:97
char shutdownRequested
Definition: twThreads.h:38