text: 
  #include "classify2thread.h"
  #include "pipeline.h"
  #include "recdopt.h"
  
  
  Classify2Thread::Classify2Thread() :
      ThreadBase()
  {
      m_nLogId = LOG_ID("Classify2Thread");
  }
  
  
  Classify2Thread::~Classify2Thread()
  {
  }
  
  
  void Classify2Thread::Run()
  {
      LOG_INFO(m_nLogId, "Started");
  
      // Get instances
      Pipeline *pipeline = Pipeline::GetInstance();
      if (!pipeline)
      {
          LOG_ERROR(m_nLogId, "Unable to get the Pipeline instance. Exiting thread.");
          return;
      }
  
      ClassifyBuffer_i *classifyBuffer = NULL;
  
      // Loop until the kill flag is set. See Pipeline::Shutdown
      while ( !shutdownRequested() )
      {
          // Wait for work - The driver signals this wait if either card has a new data or statistics buffer
          pipeline->Classify2Wait();
  
          //
          // Process All Queues until empty ----------------------------------------------------------------
          //
          while ( !pipeline->Classify2QEmpty() && !shutdownRequested() )
          {
  
              // There is data - get the next statistics buffer
              classifyBuffer = pipeline->Classify2QFront();
  
              // This can happen if we are shutting down and classifyPool is blocking on a new buffer
              if ( !classifyBuffer )
                  continue;
  
              uint32_t card = classifyBuffer->GetCardSource()-1;
              if ( !classifyBuffer->IsClassified() )
              {
                  if ( classifyBuffer->Classify() )
                  {
                      // Hand off to the time order thread
                      pipeline->FollowQPushBack(card, classifyBuffer);
  
                      // No Time Order Mode
                      //pipeline->DriverQPushBack(card, DATA, classifyBuffer);
                  }
                  else
                  {
                      LOG_ERROR(m_nLogId, "Classify2 Data Buffer Failed %u Card %u. Pushing back to the driver. ",
                                classifyBuffer->GetId(), card+1);
  
                      // Classify failed for this buffer. Give back to the driver
                      pipeline->DriverQPushBack(card, DATA, classifyBuffer);
                  }
              }
              else
              {
                  // Inform the pipeline we are completely done with this work
                  pipeline->FollowQPushBack(card, classifyBuffer);
              }
          }
      }
  
      LOG_INFO(m_nLogId, "Stopped");
  }
  
  