Update call_slot() API, inform caller if slot cannot be queued
It can happen that ::get_request() returns NULL if the EventPool is full. In that case the slot is never called. In this case the caller can now take action.
This commit is contained in:
parent
03e0fe0a73
commit
95aa39d1c4
@ -431,13 +431,13 @@ AbstractUI<RequestObject>::send_request (RequestObject *req)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename RequestObject> void
|
||||
template<typename RequestObject> bool
|
||||
AbstractUI<RequestObject>::call_slot (InvalidationRecord* invalidation, const boost::function<void()>& f)
|
||||
{
|
||||
if (caller_is_self()) {
|
||||
DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 direct dispatch of call slot via functor @ %3, invalidation %4\n", event_loop_name(), pthread_name(), &f, invalidation));
|
||||
f ();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* object destruction may race with realtime signal emission.
|
||||
@ -453,7 +453,7 @@ AbstractUI<RequestObject>::call_slot (InvalidationRecord* invalidation, const bo
|
||||
if (invalidation) {
|
||||
if (!invalidation->valid()) {
|
||||
DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 ignoring call-slot using functor @ %3, dead invalidation %4\n", event_loop_name(), pthread_name(), &f, invalidation));
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
invalidation->ref ();
|
||||
invalidation->event_loop = this;
|
||||
@ -465,7 +465,10 @@ AbstractUI<RequestObject>::call_slot (InvalidationRecord* invalidation, const bo
|
||||
if (invalidation) {
|
||||
invalidation->unref ();
|
||||
}
|
||||
return;
|
||||
/* event is lost, this can be critical in some cases, so
|
||||
* inform the caller. See also Session::process_rtop
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 queue call-slot using functor @ %3, invalidation %4\n", event_loop_name(), pthread_name(), &f, invalidation));
|
||||
@ -485,6 +488,7 @@ AbstractUI<RequestObject>::call_slot (InvalidationRecord* invalidation, const bo
|
||||
req->invalidation = invalidation;
|
||||
|
||||
send_request (req);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename RequestObject> void*
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
virtual ~AbstractUI();
|
||||
|
||||
void register_thread (pthread_t, std::string, uint32_t num_requests);
|
||||
void call_slot (EventLoop::InvalidationRecord*, const boost::function<void()>&);
|
||||
bool call_slot (EventLoop::InvalidationRecord*, const boost::function<void()>&);
|
||||
Glib::Threads::Mutex& slot_invalidation_mutex() { return request_buffer_map_lock; }
|
||||
|
||||
Glib::Threads::Mutex request_buffer_map_lock;
|
||||
@ -98,7 +98,7 @@ protected:
|
||||
|
||||
RequestObject* get_request (RequestType);
|
||||
void handle_ui_requests ();
|
||||
void send_request (RequestObject *);
|
||||
void send_request (RequestObject*);
|
||||
|
||||
virtual void do_request (RequestObject *) = 0;
|
||||
PBD::ScopedConnection new_thread_connection;
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
virtual void call_slot (InvalidationRecord*, const boost::function<void()>&) = 0;
|
||||
virtual bool call_slot (InvalidationRecord*, const boost::function<void()>&) = 0;
|
||||
virtual Glib::Threads::Mutex& slot_invalidation_mutex() = 0;
|
||||
|
||||
std::string event_loop_name() const { return _name; }
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
run_loop_thread = Glib::Threads::Thread::self ();
|
||||
}
|
||||
|
||||
void call_slot (InvalidationRecord* ir, const boost::function<void()>& f)
|
||||
bool call_slot (InvalidationRecord* ir, const boost::function<void()>& f)
|
||||
{
|
||||
if (Glib::Threads::Thread::self () == run_loop_thread) {
|
||||
cout << string_compose ("%1/%2 direct dispatch of call slot via functor @ %3, invalidation %4\n", event_loop_name (), pthread_name (), &f, ir);
|
||||
@ -119,6 +119,7 @@ public:
|
||||
assert (!ir);
|
||||
f (); // XXX TODO, queue and process during run ()
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void run ()
|
||||
|
@ -96,10 +96,11 @@ class MyEventLoop : public sigc::trackable, public EventLoop
|
||||
run_loop_thread = Glib::Threads::Thread::self();
|
||||
}
|
||||
|
||||
void call_slot (InvalidationRecord*, const boost::function<void()>& f) {
|
||||
bool call_slot (InvalidationRecord*, const boost::function<void()>& f) {
|
||||
if (Glib::Threads::Thread::self() == run_loop_thread) {
|
||||
f ();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Glib::Threads::Mutex& slot_invalidation_mutex() { return request_buffer_map_lock; }
|
||||
|
Loading…
Reference in New Issue
Block a user