Home
Roadside
Carputer
geoHist
software
FRC
Blog
Now you can download a copy of these docs so you can use them offline!
Download now
Main Page
Related Pages
Classes
Files
File List
networktables2
thread
DefaultThreadManger.cpp
1
/*
2
* DefaultThreadManger.cpp
3
*
4
* Created on: Sep 21, 2012
5
* Author: Mitchell Wills
6
*/
7
8
#include "networktables2/thread/DefaultThreadManager.h"
9
#include <stdio.h>
10
11
12
PeriodicNTThread::PeriodicNTThread(
PeriodicRunnable
* _r,
const
char
* _name) :
13
name(_name), thread(new NTTask(name, (FUNCPTR)
PeriodicNTThread
::taskMain)), r(_r), run(true){
14
fprintf(stdout,
"Starting task: %s\n"
, name);
15
fflush(stdout);
16
thread->Start((UINT32)
this
);
17
}
18
19
PeriodicNTThread::~PeriodicNTThread(){
20
//TODO somehow do this async
21
//delete thread;
22
}
23
int
PeriodicNTThread::taskMain(
PeriodicNTThread
* o){
//static wrapper
24
return
o->_taskMain();
25
}
26
int
PeriodicNTThread::_taskMain(){
27
try
{
28
while
(run){
29
r->
run
();
30
}
31
}
catch
(...) {
32
fprintf(stdout,
"NTTask exited with uncaught exception %s\n"
, name);
33
fflush(stdout);
34
return
1;
35
}
36
fprintf(stdout,
"NTTask exited normally: %s\n"
, name);
37
fflush(stdout);
38
return
0;
39
}
40
void
PeriodicNTThread::stop
() {
41
run =
false
;
42
}
43
bool
PeriodicNTThread::isRunning
() {
44
return
thread->IsReady();
45
}
46
47
NTThread
*
DefaultThreadManager::newBlockingPeriodicThread
(
PeriodicRunnable
* r,
const
char
* name) {
48
return
new
PeriodicNTThread
(r, name);
49
}
DefaultThreadManager::newBlockingPeriodicThread
virtual NTThread * newBlockingPeriodicThread(PeriodicRunnable *r, const char *name)
Definition:
DefaultThreadManger.cpp:47
PeriodicRunnable::run
virtual void run()=0
PeriodicNTThread::isRunning
virtual bool isRunning()
Definition:
DefaultThreadManger.cpp:43
PeriodicNTThread::stop
virtual void stop()
Definition:
DefaultThreadManger.cpp:40
PeriodicRunnable
Definition:
PeriodicRunnable.h:17
NTThread
Definition:
NTThread.h:16
PeriodicNTThread
Definition:
DefaultThreadManager.h:31
Generated on Sat Apr 26 2014 12:26:45 for WPILibC++ by
1.8.6
© 2006-2009 Dustin Spicuzza. All rights reserved.
Powered by Onnac
I do not condone or encourage graffiti. Please paint responsibly.