/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2009 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "threadengines/threadengine_win32.h" ThreadEngine::ThreadEngine(InspIRCd* Instance) { } void ThreadEngine::Create(Thread* thread) { ThreadData* data = new ThreadData; thread->state = data; DWORD ThreadId = 0; data->handle = CreateThread(NULL,0,ThreadEngine::Entry,thread,0,&ThreadId); if (data->handle == NULL) { thread->state = NULL; delete data; throw CoreException(std::string("Unable to create new thread: ") + dlerror()); } } ThreadEngine::~ThreadEngine() { } DWORD WINAPI ThreadEngine::Entry(void* parameter) { Thread* pt = reinterpret_cast(parameter); pt->Run(); return 0; } void ThreadData::FreeThread(Thread* thread) { thread->SetExitFlag(); WaitForSingleObject(handle,INFINITE); }