6#if defined(DART_HOST_OS_WINDOWS) && !defined(DART_USE_ABSL)
18class ThreadStartData {
20 ThreadStartData(
const char*
name,
23 : name_(
name), function_(
function), parameter_(parameter) {}
25 const char*
name()
const {
return name_; }
27 uword parameter()
const {
return parameter_; }
40static unsigned int __stdcall ThreadEntry(
void* data_ptr) {
41 ThreadStartData*
data =
reinterpret_cast<ThreadStartData*
>(data_ptr);
56 ThreadStartData* start_data =
new ThreadStartData(
name,
function, parameter);
59 ThreadEntry, start_data, 0, &tid);
60 if ((thread == -1L) || (thread == 0)) {
62 fprintf(stderr,
"_beginthreadex error: %d (%s)\n", errno, strerror(errno));
68 CloseHandle(
reinterpret_cast<HANDLE>(thread));
81 return ::GetCurrentThreadId();
89 InitializeSRWLock(&data_.lock_);
95 AcquireSRWLockExclusive(&data_.lock_);
110 InitializeCriticalSection(&data_.cs_);
111 InitializeConditionVariable(&data_.cond_);
115 DeleteCriticalSection(&data_.cs_);
119 EnterCriticalSection(&data_.cs_);
123 LeaveCriticalSection(&data_.cs_);
129 SleepConditionVariableCS(&data_.cond_, &data_.cs_, INFINITE);
133 if (!SleepConditionVariableCS(&data_.cond_, &data_.cs_, millis)) {
155 WakeConditionVariable(&data_.cond_);
159 WakeAllConditionVariable(&data_.cond_);
static constexpr int64_t kNoTimeout
WaitResult Wait(int64_t millis)
WaitResult WaitMicros(int64_t micros)
static const ThreadId kInvalidThreadId
void(* ThreadStartFunction)(uword parameter)
static intptr_t GetMaxStackSize()
static int Start(const char *name, ThreadStartFunction function, uword parameters)
static bool Compare(ThreadId a, ThreadId b)
static ThreadId GetCurrentThreadId()
Dart_NativeFunction function
constexpr intptr_t kMicrosecondsPerMillisecond
constexpr intptr_t kWordSize
static int8_t data[kExtLength]
WINBASEAPI BOOLEAN WINAPI TryAcquireSRWLockExclusive(_Inout_ PSRWLOCK SRWLock)
WINBASEAPI _Releases_exclusive_lock_ SRWLock VOID WINAPI ReleaseSRWLockExclusive(_Inout_ PSRWLOCK SRWLock)
WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI GetLastError(VOID)