|
@@ -151,19 +151,26 @@ int main(int argc, char *argv[]) {
|
|
|
if (rc != 0)
|
|
|
throw(L"pthread_mutexattr_destroy returns " + rc);
|
|
|
|
|
|
- for (int i = 0; i < 5; i++) {//TODO this can be simplified!
|
|
|
- if (i == THREAD_MAIN)
|
|
|
- rc = pthread_create(&thread[i], &attr, mainLoop, (void *) i);
|
|
|
- else if (i == THREAD_STRIPE)
|
|
|
- rc = pthread_create(&thread[i], NULL, stripeThread, (void *) i);
|
|
|
- else if (i == THREAD_DISPLAY)
|
|
|
- rc = pthread_create(&thread[i], NULL, displayThread, (void *) i);
|
|
|
- else if (i == THREAD_COFFEE)
|
|
|
- rc = pthread_create(&thread[i], NULL, coffeeThread, (void *) i);
|
|
|
- else if (i == THREAD_SERVER && !optNoNet)
|
|
|
- rc = pthread_create(&thread[i], NULL, serverThread, (void *) i);
|
|
|
- if (rc) {
|
|
|
- logger_error("Error:unable to create thread %d (%d)\n", i, rc);
|
|
|
+
|
|
|
+ if ((rc = pthread_create(&thread[THREAD_MAIN], &attr, mainLoop, (void *) THREAD_MAIN))) {
|
|
|
+ logger_error("Error:unable to create thread THREAD_MAIN %d (%d)\n", THREAD_MAIN, rc);
|
|
|
+ exit(-1);
|
|
|
+ }
|
|
|
+ if ((rc = pthread_create(&thread[THREAD_STRIPE], NULL, stripeThread, (void *) THREAD_STRIPE))) {
|
|
|
+ logger_error("Error:unable to create thread THREAD_STRIPE %d (%d)\n", THREAD_STRIPE, rc);
|
|
|
+ exit(-1);
|
|
|
+ }
|
|
|
+ if ((rc = pthread_create(&thread[THREAD_DISPLAY], NULL, displayThread, (void *) THREAD_DISPLAY))) {
|
|
|
+ logger_error("Error:unable to create thread THREAD_DISPLAY %d (%d)\n", THREAD_DISPLAY, rc);
|
|
|
+ exit(-1);
|
|
|
+ }
|
|
|
+ if ((rc = pthread_create(&thread[THREAD_COFFEE], NULL, coffeeThread, (void *) THREAD_COFFEE))) {
|
|
|
+ logger_error("Error:unable to create thread THREAD_COFFEE %d (%d)\n", THREAD_COFFEE, rc);
|
|
|
+ exit(-1);
|
|
|
+ }
|
|
|
+ if (!optNoNet) {
|
|
|
+ if ((rc = pthread_create(&thread[THREAD_SERVER], NULL, serverThread, (void *) THREAD_SERVER))) {
|
|
|
+ logger_error("Error:unable to create thread THREAD_SERVER %d (%d)\n", THREAD_SERVER, rc);
|
|
|
exit(-1);
|
|
|
}
|
|
|
}
|
|
@@ -195,7 +202,6 @@ void terminationHandler(int signum) {
|
|
|
logger(V_NONE, "Caught signal %d, exiting gracefully..\n", signum);
|
|
|
stopTimers();
|
|
|
|
|
|
- //TODO This event is not fired anymore...
|
|
|
event_trigger("terminate");
|
|
|
|
|
|
/*logger(V_NONE, "Saving my state to the database..\n");
|