Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-event/src/redraw.rs')
| -rw-r--r-- | helix-event/src/redraw.rs | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/helix-event/src/redraw.rs b/helix-event/src/redraw.rs index d1a18899..a9915223 100644 --- a/helix-event/src/redraw.rs +++ b/helix-event/src/redraw.rs @@ -5,20 +5,16 @@ use std::future::Future; use parking_lot::{RwLock, RwLockReadGuard}; use tokio::sync::Notify; -use crate::runtime_local; - -runtime_local! { - /// A `Notify` instance that can be used to (asynchronously) request - /// the editor to render a new frame. - static REDRAW_NOTIFY: Notify = Notify::const_new(); - - /// A `RwLock` that prevents the next frame from being - /// drawn until an exclusive (write) lock can be acquired. - /// This allows asynchronous tasks to acquire `non-exclusive` - /// locks (read) to prevent the next frame from being drawn - /// until a certain computation has finished. - static RENDER_LOCK: RwLock<()> = RwLock::new(()); -} +/// A `Notify` instance that can be used to (asynchronously) request +/// the editor the render a new frame. +static REDRAW_NOTIFY: Notify = Notify::const_new(); + +/// A `RwLock` that prevents the next frame from being +/// drawn until an exclusive (write) lock can be acquired. +/// This allows asynchsonous tasks to acquire `non-exclusive` +/// locks (read) to prevent the next frame from being drawn +/// until a certain computation has finished. +static RENDER_LOCK: RwLock<()> = RwLock::new(()); pub type RenderLockGuard = RwLockReadGuard<'static, ()>; @@ -51,12 +47,3 @@ pub fn start_frame() { pub fn lock_frame() -> RenderLockGuard { RENDER_LOCK.read() } - -/// A zero sized type that requests a redraw via [request_redraw] when the type [Drop]s. -pub struct RequestRedrawOnDrop; - -impl Drop for RequestRedrawOnDrop { - fn drop(&mut self) { - request_redraw(); - } -} |