File: ThreadPool.h

package info (click to toggle)
libseqlib 1.2.0%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,312 kB
  • sloc: cpp: 7,376; makefile: 63; sh: 5
file content (32 lines) | stat: -rw-r--r-- 577 bytes parent folder | download | duplicates (7)
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
#ifndef SEQLIB_THREAD_POOL_H
#define SEQLIB_THREAD_POOL_H

#include <stdexcept>
#include "SeqLib/BamWalker.h"
#include "htslib/thread_pool.h"

namespace SeqLib{

class ThreadPool {

 public: 
  
 ThreadPool() : nthreads(1) { p.pool = NULL; }

 ThreadPool(int n) : nthreads(1) {
    p.pool = NULL;
    if (n < 1)
      throw std::invalid_argument( "n threads must be > 0");
    if (!(p.pool = hts_tpool_init(n))) 
      throw std::runtime_error( "Error creating thread pool");
  }

  bool IsOpen() { return p.pool != NULL; }

  htsThreadPool p;
  size_t nthreads;

};

}
#endif