diff options
author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2021-04-29 05:19:06 +0200 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2021-05-03 21:11:33 -0700 |
commit | f52496c70f5bb1607908412f5ffe25b6f35df45e (patch) | |
tree | d20f14ed5640e88b0b15e3c15d22a333c7736923 /gi/toggle.h | |
parent | 02df4431c90aad7d073b8e5f2fd023539d1b4442 (diff) | |
download | gjs-f52496c70f5bb1607908412f5ffe25b6f35df45e.tar.gz |
object: Rely on next ToggleQueue iteration to handle already queued toggle events
When handling the toggle events from the main thread, we may have
received a notification for a toggle event from multiple threads
concurrently causing us to consider this an error.
For example:
Object 0x555555643b30 Toggle up, from main thread 1, queued down 1, up 1
Object 0x555555643b30 Toggle down, from main thread 1, queued down 1, up 1
Object 0x555555643b30 Toggle up, from main thread 0, queued down 0, up 0
Object 0x555555643b30 Toggle up, from main thread 1, queued down 0, up 0
Object 0x555555643b30 Toggle down, from main thread 0, queued down 0, up 0
Object 0x555555643b30 Toggle down, from main thread 1, queued down 1, up 0
Till the introduction of locked operations during toggle notifications
we may not be sure how to handle this, but now we can be quite confident
that we're working with the actual toggle queue state and so when an
already-toggled event happens we can just be sure that it will be
handled at next idle, and so we can stop considering it an error.
To avoid having a queue of events that have no result, change the
enqueue code to cancel a previously queued event that is the opposite of
the one we're adding. We need to be able to add multiple events of the
same type though (as could come from different threads), so adapt the
cancellation code to this.
As it's just something we can't control our level, but depends on other
threads fired by applications. What we can do is only react properly,
and now we do.
Fixes: #297
Diffstat (limited to 'gi/toggle.h')
-rw-r--r-- | gi/toggle.h | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/gi/toggle.h b/gi/toggle.h index df38f551..17f22c06 100644 --- a/gi/toggle.h +++ b/gi/toggle.h @@ -67,9 +67,6 @@ public: [[nodiscard]] std::deque<Item>::const_iterator find_operation_locked( const ObjectInstance* obj, Direction direction) const; - [[nodiscard]] bool find_and_erase_operation_locked( - const ObjectInstance* obj, Direction direction); - static gboolean idle_handle_toggle(void *data); static void idle_destroy_notify(void *data); |