Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generic/threadshare/src/runtime/executor/reactor.rs17
-rw-r--r--generic/threadshare/src/runtime/executor/scheduler.rs2
2 files changed, 16 insertions, 3 deletions
diff --git a/generic/threadshare/src/runtime/executor/reactor.rs b/generic/threadshare/src/runtime/executor/reactor.rs
index d93ba9a0c..86fa079bd 100644
--- a/generic/threadshare/src/runtime/executor/reactor.rs
+++ b/generic/threadshare/src/runtime/executor/reactor.rs
@@ -123,9 +123,22 @@ impl Reactor {
})
}
- pub fn close() {
+ /// Clears the `Reactor`.
+ ///
+ /// It will be ready for reuse on current thread without reallocating.
+ pub fn clear() {
let _ = CURRENT_REACTOR.try_with(|cur_reactor| {
- *cur_reactor.borrow_mut() = None;
+ cur_reactor.borrow_mut().as_mut().map(|reactor| {
+ reactor.ticker = AtomicUsize::new(0);
+ reactor.wakers.clear();
+ reactor.sources.clear();
+ reactor.events.clear();
+ reactor.timers.clear();
+ reactor.after_timers.clear();
+ while !reactor.timer_ops.is_empty() {
+ let _ = reactor.timer_ops.pop();
+ }
+ })
});
}
diff --git a/generic/threadshare/src/runtime/executor/scheduler.rs b/generic/threadshare/src/runtime/executor/scheduler.rs
index 9f862a664..ba4d6fa62 100644
--- a/generic/threadshare/src/runtime/executor/scheduler.rs
+++ b/generic/threadshare/src/runtime/executor/scheduler.rs
@@ -242,7 +242,7 @@ impl Scheduler {
context_name,
);
- Reactor::close();
+ Reactor::clear();
let _ = CURRENT_SCHEDULER.try_with(|cur_scheduler| {
*cur_scheduler.borrow_mut() = None;