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)
|
AbstractUI<RequestObject>::call_slot (InvalidationRecord* invalidation, const boost::function<void()>& f)
|
||||||
{
|
{
|
||||||
if (caller_is_self()) {
|
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));
|
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 ();
|
f ();
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* object destruction may race with realtime signal emission.
|
/* object destruction may race with realtime signal emission.
|
||||||
@ -453,7 +453,7 @@ AbstractUI<RequestObject>::call_slot (InvalidationRecord* invalidation, const bo
|
|||||||
if (invalidation) {
|
if (invalidation) {
|
||||||
if (!invalidation->valid()) {
|
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));
|
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->ref ();
|
||||||
invalidation->event_loop = this;
|
invalidation->event_loop = this;
|
||||||
@ -465,7 +465,10 @@ AbstractUI<RequestObject>::call_slot (InvalidationRecord* invalidation, const bo
|
|||||||
if (invalidation) {
|
if (invalidation) {
|
||||||
invalidation->unref ();
|
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));
|
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;
|
req->invalidation = invalidation;
|
||||||
|
|
||||||
send_request (req);
|
send_request (req);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RequestObject> void*
|
template<typename RequestObject> void*
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
virtual ~AbstractUI();
|
virtual ~AbstractUI();
|
||||||
|
|
||||||
void register_thread (pthread_t, std::string, uint32_t num_requests);
|
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& slot_invalidation_mutex() { return request_buffer_map_lock; }
|
||||||
|
|
||||||
Glib::Threads::Mutex request_buffer_map_lock;
|
Glib::Threads::Mutex request_buffer_map_lock;
|
||||||
@ -98,7 +98,7 @@ protected:
|
|||||||
|
|
||||||
RequestObject* get_request (RequestType);
|
RequestObject* get_request (RequestType);
|
||||||
void handle_ui_requests ();
|
void handle_ui_requests ();
|
||||||
void send_request (RequestObject *);
|
void send_request (RequestObject*);
|
||||||
|
|
||||||
virtual void do_request (RequestObject *) = 0;
|
virtual void do_request (RequestObject *) = 0;
|
||||||
PBD::ScopedConnection new_thread_connection;
|
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;
|
virtual Glib::Threads::Mutex& slot_invalidation_mutex() = 0;
|
||||||
|
|
||||||
std::string event_loop_name() const { return _name; }
|
std::string event_loop_name() const { return _name; }
|
||||||
|
@ -109,7 +109,7 @@ public:
|
|||||||
run_loop_thread = Glib::Threads::Thread::self ();
|
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) {
|
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);
|
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);
|
assert (!ir);
|
||||||
f (); // XXX TODO, queue and process during run ()
|
f (); // XXX TODO, queue and process during run ()
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void run ()
|
void run ()
|
||||||
|
@ -96,10 +96,11 @@ class MyEventLoop : public sigc::trackable, public EventLoop
|
|||||||
run_loop_thread = Glib::Threads::Thread::self();
|
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) {
|
if (Glib::Threads::Thread::self() == run_loop_thread) {
|
||||||
f ();
|
f ();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::Threads::Mutex& slot_invalidation_mutex() { return request_buffer_map_lock; }
|
Glib::Threads::Mutex& slot_invalidation_mutex() { return request_buffer_map_lock; }
|
||||||
|
Loading…
Reference in New Issue
Block a user