//**************************************************************************************************
//
// THREAD RELATED TYPES:
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#pragma once
#include "include_restrictions.h"
namespace RuntimeForStatic {

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$ThreadStart"-TYPE (FUNCTION POINTER):
//
//==================================================================================================
typedef UINT (__stdcall *$ThreadStart)(PVOID argumentPointer $optional);
//==================================================================================================


//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$CRTLocaleStrings"-STRUCTURE:
//
//==================================================================================================
struct $CRTLocaleStrings
{
   PCSTR
      ALL      $optional,
      COLLATE  $optional,
      CTYPE    $optional,
      MONETARY $optional,
      NUMERIC  $optional,
      TIME     $optional;
}; // $CRTLocaleStrings
typedef $CRTLocaleStrings*       $PCRTLocaleStrings;
typedef const $CRTLocaleStrings* $PCCRTLocaleStrings;
//==================================================================================================


//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$ThreadSettings"-STRUCTURE:
//
//==================================================================================================
struct $ThreadSettings
{
   LANGID   LanguageId        $optional;
   LCID     LocaleId          $optional;
   bool     DontReplaceEmptyLocaleValues;
   bool     AllowZeroLocaleIdApplying;
   $CRTLocaleStrings
            CRTLocaleStrings;
   bool     StartupCustomizationFailureAsFatalError;
   void ReplaceEmptyLocaleValues();
}; // $ThreadSettings
typedef $ThreadSettings*       $PThreadSettings;
typedef const $ThreadSettings* $PCThreadSettings;
//==================================================================================================


//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$Thread" STATIC CLASS:
//
//==================================================================================================
class $Thread $requires_rt_init
{
$STATIC_CLASS( $Thread )
public:
   static bool IsInitialized() $thread_static $not_requires_rt_init;
   static void VerifyInitialized($O) $thread_static $requires_rt_n_thread_init;
   static bool InitializeThread($OA, $DynText& errorMessage $out ) $thread_static;
   static bool InitializeThread($OA, $PCThreadSettings threadSettingsPtr $optional,
                                     $DynText& errorMessage $out ) $thread_static;
   static bool InitializeThread($OA, $PThreadSettings pThreadSettings $persistent_ptr,
                                     bool createThreadSettingsClone,
                                     $DynText& errorMessage $out ) $thread_static;
   static void FinalizeThread() $thread_static;
public:
   static bool IsInMainThread() $not_requires_rt_init;
   static LANGID LanguageId() $thread_static;
   static LCID LocaleId() $thread_static;
public:
   static HANDLE Create($OA,
      $ThreadStart threadStart, PVOID argumentPointer $optional, PUINT pThreadId $out $optional )
      $null_on_failure $last_error;
   static HANDLE Create($OA,
      PVOID security $optional, UINT stackSize $optional, $ThreadStart threadStart,
      PVOID argumentPointer $optional, UINT threadFlag $optional, PUINT pThreadId $out $optional )
      $null_on_failure $last_error;
   static HANDLE CreateSuspended($OA,
      $ThreadStart threadStart, PVOID argumentPointer $optional, PUINT pThreadId $out $optional )
      $null_on_failure $last_error;
   static HANDLE CreateSuspended($OA,
      PVOID security $optional, UINT stackSize $optional, $ThreadStart threadStart,
      PVOID argumentPointer $optional, PUINT pThreadId $out $optional )
      $null_on_failure $last_error;
   static HANDLE CreateEx($OA,
      PVOID security $optional, UINT stackSize $optional, $ThreadStart threadStart,
      PVOID argumentPointer $optional, UINT threadFlag $optional, PUINT pThreadId $out $optional,
      $PCThreadSettings pSettings $optional )
      $null_on_failure $last_error;
   static bool Join($OA,HANDLE hThread) $last_error;
   static bool Join($OA,HANDLE hThread,DWORD& exitCode $out) $last_error;
public:
   static void Hang() $not_returns $not_requires_rt_init;
private:
#include "..\private\Thread.private.h"
}; // $Thread
//==================================================================================================

} // RuntimeForStatic
