Send correct informations to a http tracker.
[tairent.git] / src / main / mainthread.cpp
blobeb7dcbbc40a6aca2809f8f9c646d96f5d0856ac6
1 /***************************************************************************
2 * *
3 * Copyright (C) 2006 David Brodsky *
4 * *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License as *
7 * published by the Free Software Foundation and appearing *
8 * in the file LICENSE.GPL included in the packaging of this file. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * General Public License for more details. *
14 * *
15 ***************************************************************************/
17 #include <cstdio>
18 #include <signal.h>
20 #include <tairon/core/log.h>
22 #include "mainthread.h"
24 static unsigned int todoCounter = 1;
26 /* {{{ signalHandler(int) */
27 static void signalHandler(int)
29 INFO("Signal caught, terminating");
31 signal(SIGINT, SIG_DFL);
32 todoCounter -= 1;
34 /* }}} */
36 namespace Tairent
39 namespace Main
42 MainThread *MainThread::mainThread = 0;
44 /* {{{ MainThread::MainThread() */
45 MainThread::MainThread() : Tairon::Core::Thread("main")
47 signal(SIGINT, signalHandler);
48 signal(SIGUSR1, signalHandler);
50 /* }}} */
52 /* {{{ MainThread::~MainThread() */
53 MainThread::~MainThread()
56 /* }}} */
58 /* {{{ MainThread::operationDone() */
59 void MainThread::operationDone()
61 todoCounter += 1;
63 /* }}} */
65 /* {{{ MainThread::operationInProgress() */
66 void MainThread::operationInProgress()
68 todoCounter -= 1;
70 /* }}} */
72 /* {{{ MainThread::run() */
73 void *MainThread::run()
75 while (todoCounter) {
76 waitAndCallFunctors(1, 0);
77 fflush(stdout);
80 return 0;
82 /* }}} */
84 }; // namespace Main
86 }; // namespace Tairent
88 // vim: ai sw=4 ts=4 noet fdm=marker