mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Implemented setTaskPriority() and getTaskPriority() in Task HAL API Removed all other unimplemented functions in HAL and removed spawnTask() Replaced instances of pthread_t* with TASK typedef Removed unused HAL error constants and removed commented-out classes and functions in wpilibj's HALLibrary Changed Task class API to match the construction semantics of a std::thread Change-Id: I3bc951a3da90d24c5589fae4d1ca2bb60225c873
56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
/*
|
|
* DefaultThreadManager.h
|
|
* Desktop
|
|
*
|
|
* Created on: Sep 21, 2012
|
|
* Author: Mitchell Wills
|
|
*/
|
|
|
|
#ifndef DEFAULTTHREADMANAGER_H_
|
|
#define DEFAULTTHREADMANAGER_H_
|
|
|
|
|
|
class DefaultThreadManager;
|
|
class PeriodicNTThread;
|
|
|
|
#include "networktables2/thread/PeriodicRunnable.h"
|
|
#include "networktables2/thread/NTThreadManager.h"
|
|
#include "networktables2/thread/NTThread.h"
|
|
|
|
#if defined WIN32
|
|
#include "OSAL/Task.h"
|
|
#else
|
|
#include <pthread.h>
|
|
#endif
|
|
|
|
class DefaultThreadManager : public NTThreadManager{
|
|
public:
|
|
virtual NTThread* newBlockingPeriodicThread(PeriodicRunnable* r, const char* name);
|
|
};
|
|
|
|
class PeriodicNTThread : public NTThread {
|
|
private:
|
|
#if defined WIN32
|
|
const char* name;
|
|
NTTask* thread;
|
|
#else
|
|
pthread_t thread;
|
|
#endif
|
|
PeriodicRunnable* r;
|
|
bool run;
|
|
#if defined WIN32
|
|
int _taskMain();
|
|
static int taskMain(PeriodicNTThread* o);
|
|
#else//TODO make return int for pthread as well
|
|
void _taskMain();
|
|
static void* taskMain(PeriodicNTThread* o);
|
|
#endif
|
|
public:
|
|
PeriodicNTThread(PeriodicRunnable* r, const char* name);
|
|
virtual ~PeriodicNTThread();
|
|
virtual void stop();
|
|
virtual bool isRunning();
|
|
};
|
|
|
|
#endif /* DEFAULTTHREADMANAGER_H_ */
|