This file is indexed.

/usr/include/CLAM/ThreadPool.hxx is in libclam-dev 1.4.0-6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
 *                         UNIVERSITAT POMPEU FABRA
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef __ThreadPool__
#define __ThreadPool__

#include "PooledThread.hxx"
#include "Mutex.hxx"
#include <deque>

namespace CLAM {

class PooledThread;

/**
* This is a simple variety of thread pool. This class maintains a collection
* of threads. When an additional thread is needed and no threads are available
* in its idle pool, it first checks the status of the threads it has already
* given out and returns one of those to the client and the rest to the idle
* pool. If all the threads it has given out are still busy, it creates a
* new thread.
*
* This class should only be used if a relatively small number of threads is
* needed, because as the number of threads grows, the scheduling overhead of
* switching between threads can become a significant drag on your program's
* performance. If a relatively large number of tasks need to be run on threads,
* it would be better to use a work queue which is processed by a fixed number
* of threads.
*
* \author Greg Kellum [gkellum@iua.upf.edu] 7/20/2007
* \since  CLAM v1.1.
*/
class ThreadPool
{
public:
	/**
	* The constructor.
	*
	* \arg initialNumberOfThreads - self-explanatory
	* \arg isRealtime - if the thread is declared as realtime, it will get
	*      the highest level of scheduling priority possible which might
	*      cause threads of this pool to run before any other threads.
	*      if the thread is declared as not realtime, it will get half the
	*      scheduling priority of a realtime thread.
	*/
	ThreadPool(int initialNumberOfThreads = 10, bool isRealtime = false);

	~ThreadPool();

	/**
	* This gets a thread from the pool. When an additional thread is needed
	* and no threads are available in its idle pool, it first checks the status
	* of the threads it has already given out and returns one of those to the
	* client and the rest to the idle pool. If all the threads it has given out
	* are still busy, it creates a new thread.
	*
	*/
	PooledThread* GetThreadFromPool();

	void ReturnThreadToPool(PooledThread* aThread);

	void EmptyPool();

private:
	bool mIsRealtime;
	CLAM::Mutex dequeMutex;
	std::deque<PooledThread*> idleThreads;
	std::deque<PooledThread*> busyThreads;
};

} // end namespace CLAM

#endif