Ejemplo n.º 1
0
   virtual void go()
   {
      LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);

      pthread_barrier_t bar;
      if (int err = pthread_barrier_init(&bar, NULL, count))
      {
         LOG4CPLUS_ERROR(msLogger, "pthread_barrier_init err = " + convertIntegerToString(err) + strerror(err));
         assert(false && "pthread_barrier_init err");
      }

      mpPool = new CThreadPool(count);
      CSignalSemaphore sem;

      for (UInt32 i = 0; i < count; ++i)
      {
         JobBarrierData* jbd = new JobBarrierData;
         jbd->pBar = &bar;
         jbd->pSem = &sem;
         CThreadPoolJob job(MultipleOpenCloseMultithreadTest::job, jbd);
         mpPool->addJob(job);
      }
      
      LOG4CPLUS_INFO(msLogger, "sem wait");
      sem.wait();
      LOG4CPLUS_INFO(msLogger, "sem wait done");

      delete mpPool;
   }
Ejemplo n.º 2
0
int main()
{
    CSignalSemaphore semaphore;

    //creating ivilink app object instance
    AppLibTest* appLibTest = new AppLibTest(semaphore);
    appLibTest->init();

    semaphore.waitTimeout(20000);

    //deleting ivilink app object instance
    delete appLibTest;

    return 0;
}
Ejemplo n.º 3
0
int main(int, char **)
{
   Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("utils.Test"));

   PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties"));
   LOG4CPLUS_ERROR(logger, "Test start");

   CTimeoutManager * pInstance = CTimeoutManager::getInstance();

   pInstance->addSubscriber(new CSubscriber("\n### three ###\n", 3), 500);
   pInstance->addSubscriber(new CSubscriber("\n### one ###\n", 1), 450);

   CSubscriber * pSub = new CSubscriber("\n### empty ###\n", -10);
   pInstance->addSubscriber(pSub, 500);
   pInstance->addSubscriber(new CSubscriber("\n### four ###\n", 4), 900);
   pInstance->removeSubscriber(pSub);
   pInstance->addSubscriber(new CSubscriber("\n### two ###\n", 2), 450);

   gSem.waitTimeout(2000);

   if (5 == gCount)
   {
      LOG4CPLUS_ERROR(logger, "Test passed!\n OK OK OK OK OK OK OK OK OK OK OK OK");
   }
   else
   {
      LOG4CPLUS_ERROR(logger, "Test failed, gCount = " + convertIntegerToString(gCount));
   }

   CTimeoutManager::deleteInstance();
   CTimeoutManager::getInstance(); // check quick deleteing of CTimeoutManager instance
   CTimeoutManager::deleteInstance();
}
Ejemplo n.º 4
0
   virtual void dataReceivedCallback(const UInt32 channel_id, const UInt32 read_size)
   {
      LOG4CPLUS_TRACE(msLogger, std::string("DataLostAfterChannelAlloc::bufferOverflowCallback ") + 
         "channel_id = " + convertIntegerToString(channel_id) +
         "read_size = "  + convertIntegerToString(read_size));

      data_sem.signal();
   }
Ejemplo n.º 5
0
int main()
{
   Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("samples.Applications.BasicSample"));
   PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties"));

   LOG4CPLUS_INFO(logger, " begin BasicSample main()");

   CSignalSemaphore semaphore;
   
   //creating of basic sample instance
   CBasicSample* basicSample = new CBasicSample(semaphore);

   LOG4CPLUS_INFO(logger, "basic sample created");
   semaphore.waitTimeout(20000);

   LOG4CPLUS_INFO(logger, "after wait");

   //deleting the basic sample instance
   delete basicSample;
   LOG4CPLUS_INFO(logger, "end BasicSample main()");

   return 0;
}
Ejemplo n.º 6
0
   virtual void go()
   {
      LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);

      for (int i = 0; i < max_count; ++i)
      {
         UInt32 chid = allocChannel(ePlainData, this);
         //sync_test("DataLostAfterChannelAlloc alloc sync");

         int sem_res = data_sem.waitTimeout(timeout);
         assert(0 == sem_res && "data lost, sem exited by timeout");

         sync_test("DataLostAfterChannelAlloc data sync");

         closeChannel(chid);
         sync_test("DataLostAfterChannelAlloc close sync");
      }
   }
Ejemplo n.º 7
0
	 /**
          * Callback that should be invoked when paired profile requested from other side 
          * @param a - result of operation
          * @return none
          */
         virtual void resultReceived(int a)
         {
            mpSemaphore->signal();
         }
Ejemplo n.º 8
0
	 /**
          * Callback that should be invoked when paired profile requested from other side
          * @param a, b - operands
          * @return none
          */
         virtual void operandsReceived(int a, int b)
         {
            mpSemaphore->signal();
         }
Ejemplo n.º 9
0
 virtual void OnConnectionLost(DirectionID dirId)
 {
     connLostSem.signal();
 }
Ejemplo n.º 10
0
	      /**
          * Callback that should be invoked when paired profile requested from other side 
          * @param a - result of operation
          * @return none
          */
         virtual void resultReceived(std::string a)
         {
            mpSemaphore->signal();
         }
Ejemplo n.º 11
0
	      /**
          * Callback that should be invoked when paired profile requested from other side
          * @param a, b - operands
          * @return none
          */
         virtual void operandsReceived(std::string a, std::string b)
         {
            mpSemaphore->signal();
         }