⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stafthread.cpp

📁 Software Testing Automation Framework (STAF)的开发代码
💻 CPP
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF)                              *//* (C) Copyright IBM Corp. 2001                                              *//*                                                                           *//* This software is licensed under the Common Public License (CPL) V1.0.     *//*****************************************************************************/#include "STAFOSTypes.h"#include "STAFThread.h"#include "STAFString.h"struct STAFThread{    STAFThread(STAFThreadFunc_t theFunc, void *theData)        : func(theFunc), data(theData)    { /* Do Nothing */ }    STAFThreadFunc_t func;    void *data;};static unsigned int __stdcall RealSTAFThread(void *data){    STAFThread *pThread = static_cast<STAFThread *>(data);    unsigned int rc = pThread->func(pThread->data);    delete pThread;    return 0;}STAFRC_t STAFThreadStart(STAFThreadID_t *threadID,    STAFThreadFunc_t theFunc, void *theData, unsigned int flags,    unsigned int *osRC){    unsigned threadStackSize = 0;        if (getenv("STAF_THREAD_STACK_SIZE") != NULL)    {        STAFString threadStackSizeString = getenv("STAF_THREAD_STACK_SIZE");                    if (threadStackSizeString.isDigits())        {            threadStackSize = (unsigned) threadStackSizeString.asUInt();                            threadStackSize *= 1024;                    }    }    unsigned int rc = _beginthreadex(0, threadStackSize, RealSTAFThread,                          new STAFThread(theFunc, theData), 0,                          threadID) == 0;    return (rc) ? kSTAFBaseOSError : kSTAFOk;}STAFThreadID_t STAFThreadCurrentThreadID(){    return GetCurrentThreadId();}STAFRC_t STAFThreadSleepCurrentThread(unsigned int milliseconds,                                      unsigned int *osRC){    Sleep(milliseconds);    return kSTAFOk;}STAFThreadSafeScalar_t STAFThreadSafeIncrement(STAFThreadSafeScalar_t *ptr){    return InterlockedIncrement(ptr);}STAFThreadSafeScalar_t STAFThreadSafeDecrement(STAFThreadSafeScalar_t *ptr){    return InterlockedDecrement(ptr);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -