other-licenses/7zstub/src/Windows/Thread.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Windows/Thread.h
     3 #ifndef __WINDOWS_THREAD_H
     4 #define __WINDOWS_THREAD_H
     6 #include "Handle.h"
     7 #include "Defs.h"
     9 namespace NWindows {
    11 class CThread: public CHandle
    12 {
    13   bool IsOpen() const { return _handle != 0; }
    14 public:
    15   bool Create(LPSECURITY_ATTRIBUTES threadAttributes, 
    16       SIZE_T stackSize, LPTHREAD_START_ROUTINE startAddress,
    17       LPVOID parameter, DWORD creationFlags, LPDWORD threadId)
    18   {
    19     _handle = ::CreateThread(threadAttributes, stackSize, startAddress,
    20         parameter, creationFlags, threadId);
    21     return (_handle != NULL);
    22   }
    23   bool Create(LPTHREAD_START_ROUTINE startAddress, LPVOID parameter)
    24   {
    25     DWORD threadId;
    26     return Create(NULL, 0, startAddress, parameter, 0, &threadId);
    27   }
    29   DWORD Resume()
    30     { return ::ResumeThread(_handle); }
    31   DWORD Suspend()
    32     { return ::SuspendThread(_handle); }
    33   bool Terminate(DWORD exitCode)
    34     { return BOOLToBool(::TerminateThread(_handle, exitCode)); }
    36   int GetPriority()
    37     { return ::GetThreadPriority(_handle); }
    38   bool SetPriority(int priority)
    39     { return BOOLToBool(::SetThreadPriority(_handle, priority)); }
    41   bool Wait() 
    42   { 
    43     if (!IsOpen())
    44       return true;
    45     return (::WaitForSingleObject(_handle, INFINITE) == WAIT_OBJECT_0); 
    46   }
    48 };
    50 }
    52 #endif

mercurial