Atomically to invalidate request
Yet another slightly overkill approach, but it /may/ explain crashes.
This commit is contained in:
parent
7dbdf6cc6d
commit
77845f6019
|
@ -91,7 +91,7 @@ EventLoop::invalidate_request (void* data)
|
||||||
{
|
{
|
||||||
Glib::Threads::Mutex::Lock lm (ir->event_loop->slot_invalidation_mutex());
|
Glib::Threads::Mutex::Lock lm (ir->event_loop->slot_invalidation_mutex());
|
||||||
for (list<BaseRequestObject*>::iterator i = ir->requests.begin(); i != ir->requests.end(); ++i) {
|
for (list<BaseRequestObject*>::iterator i = ir->requests.begin(); i != ir->requests.end(); ++i) {
|
||||||
(*i)->valid = false;
|
(*i)->invalidate ();
|
||||||
(*i)->invalidation = 0;
|
(*i)->invalidation = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ AbstractUI<RequestObject>::get_request (RequestType rt)
|
||||||
DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1: allocated per-thread request of type %2, caller %3\n", event_loop_name(), rt, pthread_name()));
|
DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1: allocated per-thread request of type %2, caller %3\n", event_loop_name(), rt, pthread_name()));
|
||||||
|
|
||||||
vec.buf[0]->type = rt;
|
vec.buf[0]->type = rt;
|
||||||
vec.buf[0]->valid = true;
|
vec.buf[0]->validate ();
|
||||||
return vec.buf[0];
|
return vec.buf[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ AbstractUI<RequestObject>::handle_ui_requests ()
|
||||||
if (vec.len[0] == 0) {
|
if (vec.len[0] == 0) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (vec.buf[0]->valid) {
|
if (vec.buf[0]->valid ()) {
|
||||||
/* We first need to remove the event from the list.
|
/* We first need to remove the event from the list.
|
||||||
* If the event results in object destruction, PBD::EventLoop::invalidate_request
|
* If the event results in object destruction, PBD::EventLoop::invalidate_request
|
||||||
* will delete the invalidation record (aka buf[0]), so we cannot use it after calling do_request
|
* will delete the invalidation record (aka buf[0]), so we cannot use it after calling do_request
|
||||||
|
@ -327,7 +327,7 @@ AbstractUI<RequestObject>::handle_ui_requests ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!req->valid) {
|
if (!req->valid ()) {
|
||||||
DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 handling invalid heap request, type %3, deleting\n", event_loop_name(), pthread_name(), req->type));
|
DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 handling invalid heap request, type %3, deleting\n", event_loop_name(), pthread_name(), req->type));
|
||||||
delete req;
|
delete req;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -67,12 +67,16 @@ class LIBPBD_API EventLoop
|
||||||
static void* invalidate_request (void* data);
|
static void* invalidate_request (void* data);
|
||||||
|
|
||||||
struct BaseRequestObject {
|
struct BaseRequestObject {
|
||||||
RequestType type;
|
RequestType type;
|
||||||
bool valid;
|
gint _valid;
|
||||||
InvalidationRecord* invalidation;
|
InvalidationRecord* invalidation;
|
||||||
boost::function<void()> the_slot;
|
boost::function<void()> the_slot;
|
||||||
|
|
||||||
BaseRequestObject() : valid (true), invalidation (0) {}
|
BaseRequestObject() : _valid (0), invalidation (0) {}
|
||||||
|
|
||||||
|
void validate () { g_atomic_int_set (&_valid, 1); }
|
||||||
|
void invalidate () { g_atomic_int_set (&_valid, 0); }
|
||||||
|
bool valid () { return g_atomic_int_get (&_valid) == 1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void call_slot (InvalidationRecord*, const boost::function<void()>&) = 0;
|
virtual void call_slot (InvalidationRecord*, const boost::function<void()>&) = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user