Now you can download a copy of these docs so you can use them offline! Download now
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 }
41  run = false;
42 }
44  return thread->IsReady();
45 }
46 
48  return new PeriodicNTThread(r, name);
49 }
virtual NTThread * newBlockingPeriodicThread(PeriodicRunnable *r, const char *name)
virtual void run()=0
virtual bool isRunning()

Generated on Sat Apr 26 2014 12:26:45 for WPILibC++ by doxygen 1.8.6