Rev | Line | |
---|
[1365] | 1 | #include "toimanager.h"
|
---|
| 2 | #include <limits.h>
|
---|
| 3 | #include <pthread.h>
|
---|
[1410] | 4 | #include <iostream.h>
|
---|
[1365] | 5 |
|
---|
[1684] | 6 | #ifndef MAXINT
|
---|
| 7 | #define MAXINT 2147483647
|
---|
| 8 | #endif
|
---|
| 9 |
|
---|
[1365] | 10 | TOIManager::TOIManager() {
|
---|
| 11 | reqBegin = 0;
|
---|
[1684] | 12 | reqEnd = MAXINT;
|
---|
[1365] | 13 | }
|
---|
| 14 |
|
---|
| 15 | TOIManager* TOIManager::instance = NULL;
|
---|
| 16 |
|
---|
| 17 | TOIManager* TOIManager::getManager() {
|
---|
| 18 | if (instance == NULL) instance = new TOIManager();
|
---|
| 19 | return instance;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
[1684] | 22 | void TOIManager::setRequestedSample(int begin, int end) {
|
---|
[1365] | 23 | reqBegin = begin;
|
---|
| 24 | reqEnd = end;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
[1684] | 27 | int TOIManager::getRequestedBegin() {
|
---|
[1365] | 28 | return reqBegin;
|
---|
| 29 | }
|
---|
| 30 |
|
---|
[1684] | 31 | int TOIManager::getRequestedEnd() {
|
---|
[1365] | 32 | return reqEnd;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | void TOIManager::addThread(pthread_t* t) {
|
---|
| 36 | // cout << "adding thread " << t << endl;
|
---|
| 37 | threads.push_back(t);
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | void TOIManager::joinAll() {
|
---|
| 41 | for (vector<pthread_t*>::iterator i = threads.begin();
|
---|
| 42 | i != threads.end(); i++) {
|
---|
| 43 | pthread_t* pth = *i;
|
---|
| 44 | cout << "joining thread " << pth << endl;
|
---|
| 45 | pthread_join(*pth, NULL);
|
---|
| 46 | cout << "thread joined " << pth << endl;
|
---|
| 47 | }
|
---|
| 48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.