Changeset 99e4d8f in nscp for include/thread.h


Ignore:
Timestamp:
11/24/07 00:30:28 (6 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
7e33d82
Parents:
58a724d
Message:

2007-11-23 MickeM

  • Converted to unicode (damn sometimes I HATE C++) + Added support for escaping " on the /test syntax so now you can do: CheckWMI MaxCrit=3 "MinWarn=1" "Query:load=Select * from win32_Processor"

2007-11-22 MickeM

  • Fixed so the "default path" is correct even when running as a service (issue: #96)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/thread.h

    rdc65e35 r99e4d8f  
    2626class ThreadException { 
    2727public: 
    28   std::string e_; 
    29   ThreadException(std::string e) : e_(e) { 
    30     std::cerr << e << std::endl; 
     28  std::wstring e_; 
     29  ThreadException(std::wstring e) : e_(e) { 
     30    std::wcerr << e << std::endl; 
    3131  } 
    3232}; 
     
    5858class Thread { 
    5959private: 
    60   std::string threadid_; 
     60  std::wstring threadid_; 
    6161  HANDLE hThread_;    // Thread handle 
    6262  T* pObject_;      // Wrapped object 
     
    8181   * Sets up default values 
    8282   */ 
    83   Thread(std::string threadid) : threadid_(threadid), hThread_(NULL), pObject_(NULL), uThreadID(-1), bThreadHasTerminated(false), bThreadHasBeenClosed(false) { 
     83  Thread(std::wstring threadid) : threadid_(threadid), hThread_(NULL), pObject_(NULL), uThreadID(-1), bThreadHasTerminated(false), bThreadHasBeenClosed(false) { 
    8484    hMutex_ = CreateMutex(NULL, FALSE, NULL); 
    8585    assert(hMutex_ != NULL); 
     
    9595        ; 
    9696      else if (bThreadHasBeenClosed||bThreadHasTerminated) 
    97         std::cout << "Thread has not terminated correctly: " << threadid_ << "..." << std::endl; 
     97        std::wcout << "Thread has not terminated correctly: " << threadid_ << "..." << std::endl; 
    9898      /* 
    9999      MutexLock mutex(hMutex_, 5000L); 
     
    153153      MutexLock mutex(hMutex_, 5000L); 
    154154      if (!mutex.hasMutex()) { 
    155         throw ThreadException("Could not retrieve mutex, thread (" + threadid_ + ") not started..."); 
     155        throw ThreadException(_T("Could not retrieve mutex, thread (") + threadid_ + _T(") not started...")); 
    156156      } 
    157157      if (pObject_) { 
    158         throw ThreadException("Thread already started, thread (" + threadid_ + ") not started..."); 
     158        throw ThreadException(_T("Thread already started, thread (") + threadid_ + _T(") not started...")); 
    159159      } 
    160160//      assert(hStopEvent_ == NULL); 
     
    179179      MutexLock mutex(hMutex_, delay); 
    180180      if (!mutex.hasMutex()) { 
    181         throw ThreadException("Could not retrieve mutex, thread (" + threadid_ + ") not stopped..."); 
     181        throw ThreadException(_T("Could not retrieve mutex, thread (") + threadid_ + _T(") not stopped...")); 
    182182      } 
    183183      if (!pObject_) 
     
    193193      return true; 
    194194    } 
    195     std::cerr << "Failed to terminate thread: " << threadid_ << "..." << std::endl; 
     195    std::wcerr << _T("Failed to terminate thread: ") << threadid_ << _T("...") << std::endl; 
    196196    assert(false); 
    197197    return false; 
     
    200200    MutexLock mutex(hMutex_, 5000L); 
    201201    if (!mutex.hasMutex()) { 
    202       throw ThreadException("Could not retrieve mutex, thread (" + threadid_ + ") not stopped..."); 
     202      throw ThreadException(_T("Could not retrieve mutex, thread (") + threadid_ + _T(") not stopped...")); 
    203203    } 
    204204    if (bThreadHasTerminated||bThreadHasBeenClosed) 
     
    209209    MutexLock mutex(hMutex_, 5000L); 
    210210    if (!mutex.hasMutex()) { 
    211       throw ThreadException("Could not retrieve mutex, thread (" + threadid_ + ") not stopped..."); 
     211      throw ThreadException(_T("Could not retrieve mutex, thread (") + threadid_ + _T(") not stopped...")); 
    212212    } 
    213213    if (bThreadHasTerminated||bThreadHasBeenClosed) 
     
    218218    MutexLock mutex(hMutex_, 5000L); 
    219219    if (!mutex.hasMutex()) { 
    220       throw ThreadException("Could not retrieve mutex, thread (" + threadid_ + ") not stopped..."); 
     220      throw ThreadException(_T("Could not retrieve mutex, thread (") + threadid_ + _T(") not stopped...")); 
    221221    } 
    222222    if (bThreadHasTerminated||bThreadHasBeenClosed) 
Note: See TracChangeset for help on using the changeset viewer.