/usr/include/mash/ThreadPool.h is in libmash-dev 1.1.1-2.
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 | // Copyright © 2015, Battelle National Biodefense Institute (BNBI);
// all rights reserved. Authored by: Brian Ondov, Todd Treangen,
// Sergey Koren, and Adam Phillippy
//
// See the LICENSE.txt file included with this software for license information.
#ifndef ThreadPool_h
#define ThreadPool_h
#include <pthread.h>
#include <queue>
template <class TypeInput, class TypeOutput>
class ThreadPool
{
public:
ThreadPool(TypeOutput * (* functionNew)(TypeInput *), unsigned int threadCountNew);
~ThreadPool();
bool outputAvailable() const;
TypeOutput * popOutputWhenAvailable(); // output must be deleted by calling function
bool running() const;
void runWhenThreadAvailable(TypeInput * input); // thread deletes input when finished
void runWhenThreadAvailable(TypeInput * input, TypeOutput * (* functionNew)(TypeInput *)); // thread deletes input when finished
private:
struct OutputQueueNode
{
// used to preserve input order when outputting
OutputQueueNode * prev;
OutputQueueNode * next;
TypeOutput * output;
bool ready;
};
unsigned int threadCount;
pthread_t * threads;
static void * thread(void *);
TypeOutput * (* function)(TypeInput *);
TypeInput * inputCurrent;
OutputQueueNode * outputQueueNodeCurrent;
pthread_mutex_t * mutexInput;
pthread_mutex_t * mutexOutput;
pthread_cond_t * condInput;
pthread_cond_t * condOutput;
OutputQueueNode * outputQueueHead;
OutputQueueNode * outputQueueTail;
bool finished;
friend void * thread(void *);
};
#include "ThreadPool.hxx"
#endif
|