thread.cpp
来自「功能强大的开源加密软件。使用最新ieee-p1619标准」· C++ 代码 · 共 49 行
CPP
49 行
/*
Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
Governed by the TrueCrypt License 2.4 the full text of which is contained
in the file License.txt included in TrueCrypt binary and source code
distribution packages.
*/
#include <pthread.h>
#include <unistd.h>
#include "Platform/SystemException.h"
#include "Platform/Thread.h"
#include "Platform/SystemLog.h"
namespace TrueCrypt
{
void Thread::Start (ThreadProcPtr threadProc, void *parameter)
{
pthread_t thread;
pthread_attr_t attr;
size_t stackSize = 0;
int status;
status = pthread_attr_init (&attr);
if (status != 0)
throw SystemException (SRC_POS, status);
status = pthread_attr_getstacksize (&attr, &stackSize);
if (status != 0)
throw SystemException (SRC_POS, status);
if (stackSize < MinThreadStackSize)
{
status = pthread_attr_setstacksize (&attr, MinThreadStackSize);
if (status != 0)
throw SystemException (SRC_POS, status);
}
status = pthread_create (&thread, nullptr, threadProc, parameter);
if (status != 0)
throw SystemException (SRC_POS, status);
}
void Thread::Sleep (uint32 milliSeconds)
{
::usleep (milliSeconds * 1000);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?