Exemple #1
0
void* Threadable::Start(void* arg)
{
	EnEx ee(FL, "Threadable::Start()", true);

	// Cast the argument
	Threadable* t = (Threadable*)arg;

	// Set our thread id in the threadable object:
	t->ThreadID(CURRENT_THREAD_ID);
	
	// If PreExecute fails, then don't do anything else.
	// If PreExecute goes well, then guarantee to call
	// PostExecute, even if an exception happens in Execute().
	
	try {
		t->PreExecute();
	} catch (AnException& e){
		ERRORL(FL, "Exception during PreExecute: %s", e.Msg());
		return (void*)NULL;
	} catch (std::exception& stde){
		ERRORL(FL, "STD::Exception during PreExecute: %s", stde.what() );
		return (void*)NULL;
	} catch (...){
		ERRORL(FL, "Unknown Exception during PreExecute.");
		return (void*)NULL;
	}

	try {
		t->Execute();
	} catch (AnException& e) {
		ERRORL(FL, "Exception during Execute: %s", e.Msg());
	} catch (std::exception& stde){
		ERRORL(FL, "STD::Exception during Execute: %s", stde.what() );
	} catch (...){
		ERRORL(FL, "Unknown Exception during Execute");
	}

	try {
		t->PostExecute();
	} catch (AnException& e){
		ERRORL(FL, "Exception during PostExecute: %s", e.Msg());
	} catch (std::exception& stde){
		ERRORL(FL, "STD::Exception during PostExecute: %s", stde.what() );
	} catch (...){
		ERRORL(FL, "Unknown Exception during PostExecute");
	}

	return (void*)NULL;
}
static void* ThreadFunc(void *args) {
	Threadable *self = (Threadable *)args;
	self->run();
	return NULL;
}
Exemple #3
0
static void * run_thread(void * t){
    Threadable * thread = (Threadable *)t;
    thread->run();
    return NULL;
}