mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
CMake Changes
This is the changes made by Patrick Plenefisch converting the native code to use CMake and the CMake Maven Plugin, as opposed to the native Maven plugin. This is to allow for compatibility with newer versions of the GCC toolchain. All the cpp sources were moved from maven style directories to cpp style directories for CMake. Change-Id: I67f5e3608948f37c83b0990d232105a3784f8593
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 __vxworks || 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 __vxworks || defined WIN32)
|
||||
const char* name;
|
||||
NTTask* thread;
|
||||
#else
|
||||
pthread_t thread;
|
||||
#endif
|
||||
PeriodicRunnable* r;
|
||||
bool run;
|
||||
#if (defined __vxworks || 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_ */
|
||||
34
networktables/cpp/include/networktables2/thread/NTThread.h
Normal file
34
networktables/cpp/include/networktables2/thread/NTThread.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* NTThread.h
|
||||
*
|
||||
* Created on: Sep 21, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#ifndef NTTHREAD_H_
|
||||
#define NTTHREAD_H_
|
||||
|
||||
/**
|
||||
* Represents a thread in the network tables system
|
||||
* @author mwills
|
||||
*
|
||||
*/
|
||||
class NTThread
|
||||
{
|
||||
public:
|
||||
virtual ~NTThread()
|
||||
{
|
||||
}
|
||||
;
|
||||
/**
|
||||
* stop the thread
|
||||
*/
|
||||
virtual void stop() = 0;
|
||||
|
||||
/**
|
||||
* @return true if the thread is running
|
||||
*/
|
||||
virtual bool isRunning() = 0;
|
||||
};
|
||||
|
||||
#endif /* NTTHREAD_H_ */
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* NTThreadManager.h
|
||||
*
|
||||
* Created on: Sep 21, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#ifndef NTTHREADMANAGER_H_
|
||||
#define NTTHREADMANAGER_H_
|
||||
|
||||
class NTThreadManager;
|
||||
|
||||
#include "networktables2/thread/NTThread.h"
|
||||
#include "networktables2/thread/PeriodicRunnable.h"
|
||||
|
||||
/**
|
||||
* A thread manager that can be used to obtain new threads
|
||||
*
|
||||
* @author Mitchell
|
||||
*
|
||||
*/
|
||||
class NTThreadManager
|
||||
{
|
||||
public:
|
||||
virtual ~NTThreadManager()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @param r
|
||||
* @param name the name of the thread
|
||||
* @return a thread that will run the provided runnable repeatedly with the assumption that the runnable will block
|
||||
*/
|
||||
virtual NTThread* newBlockingPeriodicThread(PeriodicRunnable* r, const char* name) = 0;
|
||||
};
|
||||
|
||||
#endif /* NTTHREADMANAGER_H_ */
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* PeriodicRunnable.h
|
||||
*
|
||||
* Created on: Sep 21, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#ifndef PERIODICRUNNABLE_H_
|
||||
#define PERIODICRUNNABLE_H_
|
||||
|
||||
/**
|
||||
* A runnable where the run method will be called periodically
|
||||
*
|
||||
* @author Mitchell
|
||||
*
|
||||
*/
|
||||
class PeriodicRunnable
|
||||
{
|
||||
public:
|
||||
virtual ~PeriodicRunnable()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* the method that will be called periodically on a thread
|
||||
*
|
||||
* @throws InterruptedException thrown when the thread is supposed to be interrupted and stop (implementers should always let this exception fall through)
|
||||
*/
|
||||
virtual void run() = 0;
|
||||
};
|
||||
|
||||
#endif /* PERIODICRUNNABLE_H_ */
|
||||
Reference in New Issue
Block a user