23 #include "workerthread.h"
24 #include "utilitiesexceptions.h"
32 waitForOperationsToDo(),
33 waitForOperationsToFinish(),
40 foreach (BaseException *e, exceptions) {
47 operations.enqueue( ThreadOperationInfo( newOperation, deleteAtEnd ) );
49 if ( operations.size() == 1 ) {
51 waitForOperationsToDo.wakeAll();
57 if ( operation.operation ) {
58 operation.operation->stop();
61 waitForOperationsToFinish.wait(&mutex);
72 if ( quitRequested ) {
76 if ( operations.size() == 0 ) {
78 waitForOperationsToDo.wait( &mutex );
80 if ( quitRequested ) {
84 operation = operations.dequeue();
87 operation.operation->run();
88 }
catch (BaseException& e) {
89 BaseException* cloned = e.clone();
90 exceptions.append(cloned);
93 }
catch (std::exception& e) {
95 exceptions.append(cloned);
100 exceptions.append(e);
105 if ( operation.deleteAtEnd ) {
106 delete operation.operation;
108 operation.operation = NULL;
110 waitForOperationsToFinish.wakeAll();
111 if ( quitRequested ) {
119 quitRequested =
true;
122 waitForOperationsToDo.wakeAll();
129 bool ret = (operation.operation != NULL);