Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
90732bb
Add new mutex and condition types
Jan 24, 2026
9f44f3f
Update c functions to use new impl
Jan 24, 2026
1b1747f
recursive mutex
Jan 24, 2026
8e0615e
Merge branch 'master' into std-synchronisation
Aidan63 Jan 24, 2026
bc1cf9a
Update src/hx/thread/ConditionVariable.cpp
Aidan63 Jan 24, 2026
b775337
Non recursive mutex for condition variable
Jan 25, 2026
63ea825
Remove timed wait which isn't actually used anywhere
Jan 25, 2026
3c17ade
Revert "Remove timed wait which isn't actually used anywhere"
Jan 25, 2026
5347182
Use an atomic_int for the thread id
Jan 25, 2026
0a7b031
Update telemetry implementations to use std::mutex
Jan 25, 2026
67cbfe1
std::mutex for __hxcpp_field_to_id
Jan 25, 2026
82ea075
std::mutex for profiler
Jan 25, 2026
7735013
std::mutex for debugging
Jan 25, 2026
33ea04d
std::mutex for gc
Jan 25, 2026
fa36391
try recursive mutex for telemetry
Jan 25, 2026
7fac36f
Revert "std::mutex for gc"
Jan 25, 2026
cb565f2
std::mutex for finaliser and root protection
Jan 25, 2026
862b923
std::mutex for large object heap
Jan 25, 2026
21ac9fa
recursive mutex for special object and state change locks
Jan 25, 2026
4c6d59b
pointers to condition variables
Jan 26, 2026
aaead48
Use wait overload instead of manual while loops
Jan 26, 2026
7ba03d0
non recursive mutex for thread pool lock
Jan 26, 2026
1f999bc
non recursive mutex for special object lock
Jan 26, 2026
5aa26a1
non recursive mutex for state change lock
Jan 26, 2026
abd300a
Remove function not used in haxe
Jan 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions include/hx/thread/ConditionVariable.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#ifndef HXCPP_H
#include <hxcpp.h>
#endif

HX_DECLARE_CLASS2(hx, thread, ConditionVariable)

namespace hx
{
namespace thread
{
struct ConditionVariable_obj : public hx::Object
{
ConditionVariable_obj();

void acquire();
bool tryAcquire();
void release();
void wait();
void signal();
void broadcast();

private:
struct Impl;

Impl* impl;
};
}
}
27 changes: 27 additions & 0 deletions include/hx/thread/RecursiveMutex.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#ifndef HXCPP_H
#include <hxcpp.h>
#endif

HX_DECLARE_CLASS2(hx, thread, RecursiveMutex)

namespace hx
{
namespace thread
{
struct RecursiveMutex_obj : public hx::Object
{
RecursiveMutex_obj();

void acquire();
void release();
bool tryAcquire();

private:
struct Impl;

Impl* impl;
Comment thread
Simn marked this conversation as resolved.
};
}
}
28 changes: 15 additions & 13 deletions src/hx/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <hx/Telemetry.h>
#include <hx/Unordered.h>
#include <hx/OS.h>
#include <mutex>


#if defined(HXCPP_CATCH_SEGV) && !defined(_MSC_VER)
Expand Down Expand Up @@ -45,7 +46,7 @@ namespace hx
const char* EXTERN_CLASS_NAME = "extern";

#ifdef HXCPP_STACK_IDS
static HxMutex sStackMapMutex;
static std::mutex sStackMapMutex;
typedef UnorderedMap<int, StackContext *> StackMap;
static StackMap sStackMap;
#endif
Expand Down Expand Up @@ -245,9 +246,10 @@ void StackContext::onThreadAttach()
#ifdef HXCPP_STACK_IDS
mThreadId = __hxcpp_GetCurrentThreadNumber();

sStackMapMutex.Lock();
sStackMap[mThreadId] = this;
sStackMapMutex.Unlock();
{
std::lock_guard<std::mutex> guard(sStackMapMutex);
sStackMap[mThreadId] = this;
}
#endif

#ifdef HXCPP_DEBUGGER
Expand Down Expand Up @@ -302,9 +304,10 @@ void StackContext::onThreadDetach()
#endif

#ifdef HXCPP_STACK_IDS
sStackMapMutex.Lock();
sStackMap.erase(mThreadId);
sStackMapMutex.Unlock();
{
std::lock_guard<std::mutex> guard(sStackMapMutex);
sStackMap.erase(mThreadId);
}
mThreadId = 0;
#endif

Expand All @@ -317,18 +320,17 @@ void StackContext::onThreadDetach()
void StackContext::getAllStackIds( QuickVec<int> &outIds )
{
outIds.clear();
sStackMapMutex.Lock();

std::lock_guard<std::mutex> guard(sStackMapMutex);

for(StackMap::iterator i=sStackMap.begin(); i!=sStackMap.end(); ++i)
outIds.push(i->first);
sStackMapMutex.Unlock();
}

StackContext *StackContext::getStackForId(int id)
{
sStackMapMutex.Lock();
StackContext *result = sStackMap[id];
sStackMapMutex.Unlock();
return result;
std::lock_guard<std::mutex> guard(sStackMapMutex);
return sStackMap[id];
}
#endif

Expand Down
Loading