1 /***************************************************************************
3 * Copyright (C) 2006 David Brodsky *
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. *
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. *
15 ***************************************************************************/
17 #include <tairon/core/mutex.h>
19 #include "hashcheckerthread.h"
21 #include "hashchecker.h"
29 HashCheckerThread
*HashCheckerThread::hashCheckerThread
= 0;
31 /* {{{ HashCheckerThread::HashCheckerThread() */
32 HashCheckerThread::HashCheckerThread() : Tairon::Core::Thread("hash"), exit(false)
34 deletingMutex
= new Tairon::Core::Mutex();
35 hashCheckerThread
= this;
39 /* {{{ HashCheckerThread::~HashCheckerThread() */
40 HashCheckerThread::~HashCheckerThread()
43 hashCheckerThread
= 0;
47 /* {{{ HashCheckerThread::addCheckerToDelete(HashChecker *) */
48 void HashCheckerThread::addCheckerToDelete(HashChecker
*checker
)
50 deletingMutex
->lock();
51 toDelete
.push_back(checker
);
52 deletingMutex
->unlock();
56 /* {{{ HashCheckerThread::run() */
57 void *HashCheckerThread::run()
60 waitAndCallFunctors(1, 0);
61 deletingMutex
->lock();
62 for (std::list
<HashChecker
*>::const_iterator it
= toDelete
.begin(); it
!= toDelete
.end(); ++it
)
65 deletingMutex
->unlock();
74 }; // namespace Tairent
76 // vim: ai sw=4 ts=4 noet fdm=marker