66 std::lock_guard<std::recursive_mutex> lock(m_slotInvocationMutex);
72 m_isEvaluating =
true;
78 for (
auto &pair : m_deferredSlotInvocations) {
83 m_deferredSlotInvocations.clear();
84 m_isEvaluating =
false;
88 m_deferredSlotInvocations.clear();
89 m_isEvaluating =
false;
111 template<
typename...>
114 void enqueueSlotInvocation(
const ConnectionHandle &handle,
const std::function<
void()> &slotInvocation)
117 std::lock_guard<std::recursive_mutex> lock(m_slotInvocationMutex);
118 m_deferredSlotInvocations.push_back({ handle, std::move(slotInvocation) });
129 std::lock_guard<std::recursive_mutex> lock(m_slotInvocationMutex);
131 if (m_isEvaluating) {
139 auto handleMatches = [&handle](
const auto &invocationPair) {
140 return invocationPair.first == handle;
144 m_deferredSlotInvocations.erase(
145 std::remove_if(m_deferredSlotInvocations.begin(), m_deferredSlotInvocations.end(), handleMatches),
146 m_deferredSlotInvocations.end());
149 std::vector<std::pair<ConnectionHandle, std::function<void()>>> m_deferredSlotInvocations;
153 std::recursive_mutex m_slotInvocationMutex;
154 bool m_isEvaluating =
false;
Manages and evaluates deferred Signal connections.
ConnectionEvaluator(ConnectionEvaluator &&other) noexcept=delete
virtual ~ConnectionEvaluator()=default
virtual void onInvocationAdded()
Called when a new slot invocation is added.
ConnectionEvaluator(const ConnectionEvaluator &) noexcept=delete
ConnectionEvaluator & operator=(const ConnectionEvaluator &) noexcept=delete
void evaluateDeferredConnections()
Evaluate the deferred connections.
ConnectionEvaluator()=default
ConnectionEvaluator & operator=(ConnectionEvaluator &&other) noexcept=delete
A ConnectionHandle represents the connection of a Signal to a slot (i.e. a function that is called wh...
The main namespace of the KDBindings library.