示例#1
0
void* Thread::_service(void* arg)
{
	ThreadFunctor* threadFunctor = (ThreadFunctor*)arg;
	void* ret = threadFunctor->f(threadFunctor->arg);
	pthread_exit(NULL);
	return ret;
}
示例#2
0
void* Thread::_service(void* arg)
{
	ThreadFunctor* threadFunctor  = static_cast<ThreadFunctor*>(arg);
	void* ret = threadFunctor->f(threadFunctor->arg);
	pthread_exit(NULL);
	delete threadFunctor;
	return ret;
}
示例#3
0
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.
        }
    }
}
示例#4
0
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");
    }
}
示例#5
0
void SuiteThreadFunctor::Test()
{
    iSem = new Semaphore("", 0);
    iFunctor = new ThreadFunctor("STFF", MakeFunctor(*this, &SuiteThreadFunctor::Run));
    iFunctor->Start();
    iSem->Wait();
    delete iFunctor;
    delete iSem;
}
示例#6
0
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();
}
示例#7
0
文件: Main.cpp 项目: astaykov/ohNet
int main(int argc, char* argv[])
{
    ThreadFunctor* t = new ThreadFunctor("MAIN", MakeFunctor(NULL, threadMain));
    t->Start();
    return 0;
}