is waiting replaced by is changed
This commit is contained in:
parent
e4b114ea55
commit
5dec8a9d55
|
@ -82,13 +82,6 @@ public:
|
||||||
qDebug() << "Cache size after flush is not ZERO!";
|
qDebug() << "Cache size after flush is not ZERO!";
|
||||||
s_curr = 0;
|
s_curr = 0;
|
||||||
}
|
}
|
||||||
//assert(s_curr == 0);
|
|
||||||
|
|
||||||
/* {
|
|
||||||
for(unsigned int i = 0; i < tokens.size(); i++) {
|
|
||||||
input->heap.push(tokens[i]);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///empty the cache. Make sure no resource is locked before calling this.
|
///empty the cache. Make sure no resource is locked before calling this.
|
||||||
|
|
|
@ -81,7 +81,7 @@ class Controller {
|
||||||
|
|
||||||
///start the various cache threads.
|
///start the various cache threads.
|
||||||
void start() {
|
void start() {
|
||||||
assert(stopped);
|
if(!stopped) return;
|
||||||
assert(!paused);
|
assert(!paused);
|
||||||
assert(caches.size() > 1);
|
assert(caches.size() > 1);
|
||||||
caches.back()->final = true;
|
caches.back()->final = true;
|
||||||
|
@ -92,30 +92,24 @@ class Controller {
|
||||||
|
|
||||||
///stops the cache threads
|
///stops the cache threads
|
||||||
void stop() {
|
void stop() {
|
||||||
|
if(stopped) return;
|
||||||
assert(!paused);
|
assert(!paused);
|
||||||
assert(!stopped);
|
|
||||||
|
|
||||||
//signal al caches to quit
|
//signal al caches to quit
|
||||||
for(int i = 0; i < caches.size(); i++)
|
for(unsigned int i = 0; i < caches.size(); i++)
|
||||||
caches[i]->quit = true;
|
caches[i]->quit = true;
|
||||||
|
|
||||||
//abort current gets
|
//abort current gets
|
||||||
for(int i = 0; i < caches.size(); i++)
|
for(unsigned int i = 0; i < caches.size(); i++)
|
||||||
caches[i]->abort();
|
caches[i]->abort();
|
||||||
|
|
||||||
//make sure all caches actually run a cycle.
|
//make sure all caches actually run a cycle.
|
||||||
for(unsigned int i = 0; i < caches.size(); i++)
|
for(unsigned int i = 0; i < caches.size(); i++)
|
||||||
caches[i]->input->check_queue.open();
|
caches[i]->input->check_queue.open();
|
||||||
|
|
||||||
for(int i = 0; i < caches.size(); i++)
|
for(unsigned int i = 0; i < caches.size(); i++)
|
||||||
caches[i]->wait();
|
caches[i]->wait();
|
||||||
/* //stop threads
|
|
||||||
for(int i = caches.size()-1; i >= 0; i--) {
|
|
||||||
caches[i]->quit = true; //hmmmmmmmmmmmmmm not very clean.
|
|
||||||
if(i == 0)
|
|
||||||
provider.check_queue.open();
|
|
||||||
else
|
|
||||||
caches[i-1]->check_queue.open(); //cache i listens on queue i-1
|
|
||||||
caches[i]->wait();
|
|
||||||
} */
|
|
||||||
stopped = true;
|
stopped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,11 +123,11 @@ class Controller {
|
||||||
assert(!paused);
|
assert(!paused);
|
||||||
|
|
||||||
//lock all doors.
|
//lock all doors.
|
||||||
for(unsigned int i = 1; i < caches.size(); i++)
|
for(unsigned int i = 0; i < caches.size(); i++)
|
||||||
caches[i]->input->check_queue.lock();
|
caches[i]->input->check_queue.lock();
|
||||||
|
|
||||||
//abort all pending calls
|
//abort all pending calls
|
||||||
for(unsigned int i = 1; i < caches.size(); i++)
|
for(unsigned int i = 0; i < caches.size(); i++)
|
||||||
caches[i]->abort();
|
caches[i]->abort();
|
||||||
|
|
||||||
//make sure no cache is running (must be done after abort! otherwise we have to wait for the get)
|
//make sure no cache is running (must be done after abort! otherwise we have to wait for the get)
|
||||||
|
@ -148,7 +142,7 @@ class Controller {
|
||||||
assert(paused);
|
assert(paused);
|
||||||
|
|
||||||
//unlock and open all doors
|
//unlock and open all doors
|
||||||
for(unsigned int i = 1; i < caches.size(); i++) {
|
for(unsigned int i = 0; i < caches.size(); i++) {
|
||||||
caches[i]->input->check_queue.unlock();
|
caches[i]->input->check_queue.unlock();
|
||||||
caches[i]->input->check_queue.open();
|
caches[i]->input->check_queue.open();
|
||||||
}
|
}
|
||||||
|
@ -177,7 +171,6 @@ class Controller {
|
||||||
bool isWaiting() {
|
bool isWaiting() {
|
||||||
bool waiting = true;
|
bool waiting = true;
|
||||||
for(int i = (int)caches.size() -1; i >= 0; i--) {
|
for(int i = (int)caches.size() -1; i >= 0; i--) {
|
||||||
//waiting &= caches[i]->isWaiting();
|
|
||||||
waiting &= caches[i]->input->check_queue.isWaiting();
|
waiting &= caches[i]->input->check_queue.isWaiting();
|
||||||
}
|
}
|
||||||
return waiting;
|
return waiting;
|
||||||
|
|
|
@ -143,7 +143,7 @@ class QDoor {
|
||||||
m.lock();
|
m.lock();
|
||||||
doorOpen = true;
|
doorOpen = true;
|
||||||
m.unlock();
|
m.unlock();
|
||||||
c.wakeAll();
|
c.wakeAll(); arglebargle
|
||||||
}
|
}
|
||||||
|
|
||||||
///attempt to enter the door. if the door is closed the thread will wait until the door is opened.
|
///attempt to enter the door. if the door is closed the thread will wait until the door is opened.
|
||||||
|
|
Loading…
Reference in New Issue