예제 #1
0
파일: Main.cpp 프로젝트: Sirkles/EasyThread
int main(int argc, char* argv[])
{
	assert(system(NULL));

	EasyThread* easyThread = new EasyThread();

	easyThread->setFunction(testFunction);
	easyThread->setArgument((void*)3000U);

	std::cout << "Is the thread active? " << (easyThread->isActive() ? "Yes, it is!" : "No, it's not.") << std::endl;

	easyThread->run();

	easyThread->setName("testFunction");

	std::cout << "Is the thread active now? " << (easyThread->isActive() ? "Yes, it is!" : "No, it's not.") << std::endl;

	// Wait until the thread ends.
	while (easyThread->isActive())
	{
		std::cout << "ayy lmao" << std::endl;
		EasyThread::sleep(1000);
	}

	delete easyThread;

	// More examples coming soon.

	return 0;
}
예제 #2
0
/*static */
void * EasyThread::entryPoint(void * pthis)
{
    EasyThread * pt = (EasyThread*) pthis;
    pt->run(pt->arg());
}