void* Thread::_service(void* arg) { ThreadFunctor* threadFunctor = (ThreadFunctor*)arg; void* ret = threadFunctor->f(threadFunctor->arg); pthread_exit(NULL); return ret; }
void* Thread::_service(void* arg) { ThreadFunctor* threadFunctor = static_cast<ThreadFunctor*>(arg); void* ret = threadFunctor->f(threadFunctor->arg); pthread_exit(NULL); delete threadFunctor; return ret; }
void SuiteThreadFunctorStartDelete::Test() { PrioSaw ps(kPrioritySystemLowest, kPrioritySystemHighest); for (TUint i=0; i< kThreadCount; i++) { ThreadFunctor* tf = new ThreadFunctor("TFSD", MakeFunctor(*this, &SuiteThreadFunctorStartDelete::Run), ps.Next()); tf->Start(); delete tf; if (i % kUpdateInterval == 0) { TEST(true); // only to show progress Thread::Sleep(100); // FreeRTOS delegates freeing of thread resources to the idle thread. We allow it to run here. } } }
void SuiteMulticast::Test() { iThread0->Start(); iThread1->Start(); iSender.Wait(); iSender.Wait(); SocketUdp send; Bwn buf(iExp); TUint i; for( i=0; i < kMsgBytes; i++) { buf.SetBytes(0); AppendUint32(buf, i); //num of bytes in this message buf.SetBytes(i + sizeof(TUint)); //use prefilled values send.Send(buf, Endpoint(iPort, kMulticastAddress)); // assume that a delay of 500ms without response implies that the message wasn't delivered try { iSender.Wait(500); iSender.Wait(500); } catch (Timeout&) { Print("SuiteMulticast - message(s) not delivered\n"); TEST(1 == 0); return; // temp } if (iSender.Clear()) { TEST(1 == 0); Print("SuiteMulticast - sent one message, received more than once\n"); } } buf.SetBytes(0); AppendUint32(buf, kQuit); send.Send(buf, Endpoint(iPort, kMulticastAddress)); try { iSender.Wait(500); iSender.Wait(500); } catch (Timeout&) { Print("SuiteMulticast - quit message(s) not delivered\n"); } }
void SuiteThreadFunctor::Test() { iSem = new Semaphore("", 0); iFunctor = new ThreadFunctor("STFF", MakeFunctor(*this, &SuiteThreadFunctor::Run)); iFunctor->Start(); iSem->Wait(); delete iFunctor; delete iSem; }
void SuiteThreadFunctor::Run() { try { TEST(iFunctor->TryWait() == false); iFunctor->Signal(); TEST(iFunctor->TryWait() == true); iFunctor->CheckCurrentForKill(); iFunctor->Kill(); TEST_THROWS(iFunctor->CheckCurrentForKill(), ThreadKill); TEST_THROWS(iFunctor->Wait(), ThreadKill); TEST_THROWS(iFunctor->TryWait(), ThreadKill); } catch(ThreadKill&) { ASSERT(0); } iSem->Signal(); }
int main(int argc, char* argv[]) { ThreadFunctor* t = new ThreadFunctor("MAIN", MakeFunctor(NULL, threadMain)); t->Start(); return 0; }