Skip to content
Permalink
d709efa10f
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
51 lines (45 sloc) 1.26 KB
/*
*
* Stores the interface for building a sensor thread
* implementation.
*
*/
#include <Windows.h>
#include <stdio.h>
class SensorThread
{
public:
// Thread start 'caller' function
static DWORD __stdcall threadStart(LPVOID pUserData) {
((SensorThread*) pUserData)->threadRuntime();
return 0;
}
// Thread routine for implementation to override
virtual void threadRuntime() = 0;
// Async control
UINT8 startThread(LPVOID targs)s
{
threadArgs = targs;
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
threadStart, // thread function name
this, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
return TRUE;
};
BOOL waitForThread()
{
WaitForSingleObject(hThread, INFINITE);
return TRUE;
};
// Sync control
BOOLEAN bufferDataAvailable() { return TRUE; };
SIZE_T getBufferData(LPCSTR* bufferKeyArray, LPCSTR* bufferValueArray) { return 0; };
VOID setDataStoreValue(LPCSTR key, LPCVOID value, SIZE_T valueSize) {};
protected:
LPCVOID threadArgs;
DWORD dwThreadId;
HANDLE hThread;
};