mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-02-17 05:15:14 +00:00
threadshare: Don't drift slowly when throttling the main context
Instead of taking a new time every iteration, take it once in the beginning and add our wait time on every iteration. This prevents accumulating errors and slowly drifting.
This commit is contained in:
parent
50b9654af5
commit
f5b88d37c5
1 changed files with 3 additions and 2 deletions
|
@ -104,10 +104,10 @@ impl IOContextRunner {
|
|||
|
||||
let _ = sender.send(current_thread.handle());
|
||||
|
||||
let mut now = time::Instant::now();
|
||||
|
||||
::tokio_timer::with_default(&timer_handle, &mut enter, |mut enter| {
|
||||
::tokio_reactor::with_default(&handle, &mut enter, |enter| loop {
|
||||
let now = time::Instant::now();
|
||||
|
||||
if self.shutdown.load(atomic::Ordering::SeqCst) > RUNNING {
|
||||
break;
|
||||
}
|
||||
|
@ -130,6 +130,7 @@ impl IOContextRunner {
|
|||
);
|
||||
thread::sleep(wait - elapsed);
|
||||
}
|
||||
now += wait;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue