cartoonist / kseqpp

Fast FASTA/Q parser and writer (C++ re-implementation of kseq library)
MIT License
45 stars 8 forks source link

feature request, make threads optional #10

Open panjea opened 1 year ago

panjea commented 1 year ago

this is a great minimal library, thanks! it would be nice have std::thread as an ifdef option. these are my changes, not tested yet.

line 29

#ifdef KSEQPP_THREADS
  #include <thread>
#endif

line 100

#ifdef KSEQPP_THREADS
        std::thread worker;                             /**< @brief worker thread */
#endif

line 430

          inline void
        worker_join( )
        {
#ifdef KSEQPP_THREADS
          this->async_write( true );
          if ( this->worker.joinable() ) this->worker.join();
#else
          this->async_write( false );
#endif
        }

          inline void
        worker_start( )
        {
#ifdef KSEQPP_THREADS
          this->worker = std::thread( &KStream::writer, this );
#else
          this->writer();
#endif
        }
cartoonist commented 3 weeks ago

Thanks @panjea for your suggestion! I'm curious to know in which use case you've found this feature helpful or necessary?