本文整理汇总了C++中Thread::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ Thread::Create方法的具体用法?C++ Thread::Create怎么用?C++ Thread::Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread::Create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dlltest
int __stdcall dlltest(int a, int b) noexcept {
auto f = [](Utf8String s){
std::printf("thread %u: tls = %s\n", (unsigned)::GetCurrentThreadId(), GetString().GetStr());
GetString() = std::move(s);
std::printf("thread %u: tls = %s\n", (unsigned)::GetCurrentThreadId(), GetString().GetStr());
};
Thread t;
t.Create(Bind(f, "world"_u8s), false);
f("hello"_u8s);
t.Join();
return a + b;
}
示例2: Startup
void Thread::Startup() {
threads.init();
threads.setMax(MAX_THREADS);
Thread* main = (Thread*)malloc(
sizeof(Thread)*1);
main->main = &env->methods[manifest.entryMethod];
main->Create("Main");
#ifdef WIN32_
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
SetPriorityClass(GetCurrentThread(), HIGH_PRIORITY_CLASS);
#endif
setupSigHandler();
}
示例3: WinMain
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int cmdShow)
{
HANDLE runOnceMutex = NULL;
bool allowMultipleInst = false;
g_hinst = hInstance;
// should we allow FreeAmp to run?
struct stat st;
char path[MAX_PATH];
char arg0[MAX_PATH];
getcwd(path, sizeof(path));
strcpy(arg0, __argv[0]);
char* slash = strrchr(arg0, '\\');
if(slash)
{
*slash = 0x00;
if(strcasecmp(path, arg0))
{
chdir(arg0);
strcpy(path, arg0);
}
}
strcat(path, "\\NeedToRebootForUpdate");
if(!stat(path, &st))
{
MessageBox(NULL, kReboot, "You Need To Reboot...",
MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND);
return 0;
}
FAContext *context = new FAContext;
context->prefs = new Win32Prefs();
context->prefs->GetPrefBoolean(kAllowMultipleInstancesPref, &allowMultipleInst);
context->hInstance = hInstance;
if (!allowMultipleInst)
{
if(SendCommandLineToRealJukebox())
{
return 0;
}
runOnceMutex = CreateMutex( NULL,
TRUE,
The_BRANDING" Should Only Run One Time!");
if(GetLastError() == ERROR_ALREADY_EXISTS)
{
SendCommandLineToHiddenWindow();
CloseHandle(runOnceMutex);
return 0;
}
}
// This causes a dynamic link error on some non NT systems, and
// it didn't seem to help on multiprocessor NT systems, so I'm
// commenting it.
//if(IsWinNT() && IsMultiProcessor())
// SetProcessAffinityMask(GetCurrentProcess(), 0);
WSADATA sGawdIHateMicrosoft;
WSAStartup(0x0002, &sGawdIHateMicrosoft);
context->log = new LogFile("freeamp.log");
// find all the plug-ins we use
Registrar* registrar;
Registry* lmc;
Registry* pmi;
Registry* pmo;
Registry* ui;
registrar = new Registrar;
registrar->SetSubDir("plugins");
registrar->SetSearchString("*.lmc");
lmc = new Registry;
registrar->InitializeRegistry(lmc, context->prefs);
registrar->SetSearchString("*.pmi");
pmi = new Registry;
registrar->InitializeRegistry(pmi, context->prefs);
registrar->SetSearchString("*.pmo");
pmo = new Registry;
registrar->InitializeRegistry(pmo, context->prefs);
registrar->SetSearchString("*.ui");
ui = new Registry;
registrar->InitializeRegistry(ui, context->prefs);
//.........这里部分代码省略.........
示例4: Create
void* Thread::Create(void* arg)
{
Thread* th = static_cast<Thread*>(arg);
th->Create();
return 0;
}