Add thread safety to Object signals
* It turns out the majority of this work was done already by AThousandShips as part of #89451. This allows to do lock-less emitting of signals. * This means, that only the signal map needs to be protected, making the task simple and without risk of deadlocks, or affecting performance. * Objects can choose to not protect signals for performance (as example Node uses thread guards for protection, so these signals are not thread safe).
This commit is contained in:
parent
dbddc9ef29
commit
2f39d8ebef
4 changed files with 128 additions and 60 deletions
|
|
@ -608,7 +608,8 @@ private:
|
|||
HashMap<Callable, Slot, HashableHasher<Callable>> slot_map;
|
||||
bool removable = false;
|
||||
};
|
||||
|
||||
friend struct _ObjectSignalLock;
|
||||
mutable Mutex *signal_mutex = nullptr;
|
||||
HashMap<StringName, SignalData> signal_map;
|
||||
List<Connection> connections;
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
|
@ -756,6 +757,8 @@ protected:
|
|||
|
||||
bool _disconnect(const StringName &p_signal, const Callable &p_callable, bool p_force = false);
|
||||
|
||||
virtual bool _uses_signal_mutex() const;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
struct VirtualMethodTracker {
|
||||
void **method;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue