1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

ListenerList: Add a thread safe ListenerList type

This commit is contained in:
Anthony Nicholls 2024-06-03 09:25:30 +01:00
parent 0dfff1454c
commit c4d5ffa7ab
4 changed files with 15 additions and 9 deletions

View file

@ -73,10 +73,7 @@ namespace juce
guaranteed that no more listeners will be called.
By default a ListenerList is not thread safe. If thread-safety is required,
you can provide a thread-safe Array type as the second type parameter e.g.
@code
using ThreadSafeList = ListenerList<MyListenerType, Array<MyListenerType*, CriticalSection>>;
@endcode
use the ThreadSafeListenerList type.
When calling listeners the iteration can be escaped early by using a
"BailOutChecker". A BailOutChecker is a type that has a public member function
@ -87,8 +84,8 @@ namespace juce
@tags{Core}
*/
template <class ListenerClass,
class ArrayType = Array<ListenerClass*>>
template <typename ListenerClass,
typename ArrayType = Array<ListenerClass*>>
class ListenerList
{
public:
@ -402,4 +399,13 @@ private:
JUCE_DECLARE_NON_COPYABLE (ListenerList)
};
//==============================================================================
/**
A thread safe version of the ListenerList class.
@see ListenerList
*/
template <typename ListenerClass>
using ThreadSafeListenerList = ListenerList<ListenerClass, Array<ListenerClass*, CriticalSection>>;
} // namespace juce