Debian Codegraph @

SeqLib/ThreadPool.h

raw symbols SCIP
1 #ifndef SEQLIB_THREAD_POOL_H
2 #define SEQLIB_THREAD_POOL_H
3
4 #include <stdexcept>
5 #include "SeqLib/BamWalker.h"
6 #include "htslib/thread_pool.h"
7
8 namespace SeqLib{
9
10 class ThreadPool {
11
12 public:
13
14 ThreadPool() : nthreads(1) { p.pool = NULL; }
15
16 ThreadPool(int n) : nthreads(1) {
17 p.pool = NULL;
18 if (n < 1)
19 throw std::invalid_argument( "n threads must be > 0");
20 if (!(p.pool = hts_tpool_init(n)))
21 throw std::runtime_error( "Error creating thread pool");
22 }
23
24 bool IsOpen() { return p.pool != NULL; }
25
26 htsThreadPool p;
27 size_t nthreads;
28
29 };
30
31 }
32 #endif