mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
* Extract CEF rendered UI into a separate process and crate * Review * Review * Review * Review * Remove necessary workarounds * Block on frame copy ack * Crop and resample frames correctly * Skip blank frames * Fix deps * Fix fmt * Fix clippy warning * Review * Fix todo
42 lines
879 B
Rust
42 lines
879 B
Rust
use std::sync::Arc;
|
|
use std::sync::atomic::{AtomicBool, Ordering};
|
|
use std::sync::mpsc::Receiver;
|
|
|
|
use crate::UiEvent;
|
|
|
|
#[derive(Clone)]
|
|
pub(crate) struct EventQueue {
|
|
sender: std::sync::mpsc::Sender<UiEvent>,
|
|
terminated: Arc<AtomicBool>,
|
|
}
|
|
|
|
impl EventQueue {
|
|
pub(crate) fn new() -> (Self, Receiver<UiEvent>) {
|
|
let (sender, receiver) = std::sync::mpsc::channel();
|
|
(
|
|
Self {
|
|
sender,
|
|
terminated: Arc::new(AtomicBool::new(false)),
|
|
},
|
|
receiver,
|
|
)
|
|
}
|
|
|
|
pub(crate) fn send(&self, event: UiEvent) {
|
|
let _ = self.sender.send(event);
|
|
}
|
|
|
|
pub(crate) fn terminate(&self, event: UiEvent) {
|
|
let _ = self.sender.send(event);
|
|
self.terminated.store(true, Ordering::SeqCst);
|
|
}
|
|
|
|
pub(crate) fn mark_terminated(&self) {
|
|
self.terminated.store(true, Ordering::SeqCst);
|
|
}
|
|
|
|
pub(crate) fn is_terminated(&self) -> bool {
|
|
self.terminated.load(Ordering::SeqCst)
|
|
}
|
|
}
|