aboutsummaryrefslogtreecommitdiff
path: root/helix-event/src/redraw.rs
diff options
context:
space:
mode:
authorPascal Kuthe2023-11-30 23:03:26 +0000
committerBlaž Hrastnik2024-01-23 02:20:19 +0000
commit13ed4f6c4748019787d24c2b686d417b71604242 (patch)
tree8263b77ee05a22dfc85410345069efb3668b1877 /helix-event/src/redraw.rs
parent7d7ace551cd58f0b6d65af7a6dfa8f896d94724a (diff)
Add hook/event system
Diffstat (limited to 'helix-event/src/redraw.rs')
-rw-r--r--helix-event/src/redraw.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/helix-event/src/redraw.rs b/helix-event/src/redraw.rs
index a9915223..8fadb8ae 100644
--- a/helix-event/src/redraw.rs
+++ b/helix-event/src/redraw.rs
@@ -5,16 +5,20 @@ use std::future::Future;
use parking_lot::{RwLock, RwLockReadGuard};
use tokio::sync::Notify;
-/// 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(());
+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(());
+}
pub type RenderLockGuard = RwLockReadGuard<'static, ()>;