<commit_before>//
// ulib - a collection of useful classes
// Copyright (C) 2006,2007,2008,2012,2013 <NAME>
//
/// \file Thread.hpp Thread class
//
#pragma once

// includes
#include "Event.hpp"

#ifdef WIN32

#ifndef MS_VC_EXCEPTION
/// exception code for visual studio functions
#define MS_VC_EXCEPTION 0x406D1388
#endif

#pragma pack(push, 8)
/// thread name info struct
typedef struct tagTHREADNAME_INFO
{
   DWORD dwType;     ///< Must be 0x1000.
   LPCSTR szName;    ///< Pointer to name (in user addr space).
   DWORD dwThreadID; ///< Thread ID (-1=caller thread).
   DWORD dwFlags;    ///< Reserved for future use, must be zero.
} THREADNAME_INFO;
#pragma pack(pop)

#endif // WIN32


/// thread helper class
class Thread
{
public:
   /// sets thread name for current or specified thread
   /// \note from http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
   static void SetName(LPCTSTR pszThreadName, DWORD dwThreadId = DWORD(-1)) throw()
   {
#ifdef WIN32
      CStringA cszaThreadName;

      THREADNAME_INFO info;
      info.dwType = 0x1000;
      info.szName = cszaThreadName.GetString();
      info.dwThreadID = dwThreadId;
      info.dwFlags = 0;

      __try
      {
         RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info);
      }
      __except(EXCEPTION_EXECUTE_HANDLER)
      {
      }
#endif // WIN32
   }

   /// returns current thread id
   static DWORD CurrentId() throw()
   {
      return ::GetCurrentThreadId();
   }
};
<commit_msg>reverted removal of USES_CONVERSION in SetName()<commit_after>//
// ulib - a collection of useful classes
// Copyright (C) 2006,2007,2008,2012,2013 <NAME>
//
/// \file Thread.hpp Thread class
//
#pragma once

// includes
#include "Event.hpp"

#ifdef WIN32

#ifndef MS_VC_EXCEPTION
/// exception code for visual studio functions
#define MS_VC_EXCEPTION 0x406D1388
#endif

#pragma pack(push, 8)
/// thread name info struct
typedef struct tagTHREADNAME_INFO
{
   DWORD dwType;     ///< Must be 0x1000.
   LPCSTR szName;    ///< Pointer to name (in user addr space).
   DWORD dwThreadID; ///< Thread ID (-1=caller thread).
   DWORD dwFlags;    ///< Reserved for future use, must be zero.
} THREADNAME_INFO;
#pragma pack(pop)

#endif // WIN32


/// thread helper class
class Thread
{
public:
   /// sets thread name for current or specified thread
   /// \note from http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
   static void SetName(LPCTSTR pszThreadName, DWORD dwThreadId = DWORD(-1)) throw()
   {
#ifdef WIN32
      USES_CONVERSION;

      THREADNAME_INFO info;
      info.dwType = 0x1000;
      info.szName = T2CA(pszThreadName);
      info.dwThreadID = dwThreadId;
      info.dwFlags = 0;

      __try
      {
         RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info);
      }
      __except(EXCEPTION_EXECUTE_HANDLER)
      {
      }
#endif // WIN32
   }

   /// returns current thread id
   static DWORD CurrentId() throw()
   {
      return ::GetCurrentThreadId();
   }
};

{'fraction_non_alphanumeric': 0.11871693121693122, 'fraction_numerical': 0.035383597883597885, 'mean_word_length': 2.8388324873096447, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1505988', 'n_tokens_mistral': 1098, 'n_tokens_neox': 993, 'n_words': 274}