mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-26 10:43:46 +03:00
feat(plugin): come back to this commit if you need high-performance timers
This commit is contained in:
parent
d2aa28ce30
commit
3d926d6c03
@ -462,6 +462,18 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||
let mut plugin_id = 0;
|
||||
let mut plugin_map = HashMap::new();
|
||||
move || loop {
|
||||
// BLUEPRINT:
|
||||
/* next = binheap.get_timer(); // peek
|
||||
let event = if let Some(time) = next {
|
||||
// match for the right timeout error here...
|
||||
if let Some(event) = chan.recv_timeout(time) {
|
||||
event
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
ch.recv().unwrap()
|
||||
} */
|
||||
let (event, mut err_ctx) = receive_plugin_instructions
|
||||
.recv()
|
||||
.expect("failed to receive event on channel");
|
||||
@ -510,7 +522,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||
|
||||
let start = instance.exports.get_function("_start").unwrap();
|
||||
|
||||
// This eventually calls the `.init()` method
|
||||
// This eventually calls the `.load()` method
|
||||
start.call(&[]).unwrap();
|
||||
|
||||
plugin_map.insert(plugin_id, (instance, plugin_env));
|
||||
|
@ -1,10 +1,5 @@
|
||||
use serde::Serialize;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
path::PathBuf,
|
||||
process,
|
||||
sync::{mpsc::Sender, Arc, Mutex},
|
||||
};
|
||||
use std::{collections::HashSet, path::PathBuf, process, sync::{mpsc::Sender, Arc, Mutex}, time::{Duration, Instant}};
|
||||
use wasmer::{imports, Function, ImportObject, Store, WasmerEnv};
|
||||
use wasmer_wasi::WasiEnv;
|
||||
use zellij_tile::data::{Event, EventType, PluginIds};
|
||||
@ -30,6 +25,13 @@ pub struct PluginEnv {
|
||||
pub send_pty_instructions: SenderWithContext<PtyInstruction>, // FIXME: This should be a big bundle of all of the channels
|
||||
pub wasi_env: WasiEnv,
|
||||
pub subscriptions: Arc<Mutex<HashSet<EventType>>>,
|
||||
// FIXME: Add timers struct here! BinaryHeap?
|
||||
}
|
||||
|
||||
struct CallbackTimer {
|
||||
wake_time: Instant,
|
||||
plugin_id: u32,
|
||||
recurring: bool,
|
||||
}
|
||||
|
||||
// Plugin API ---------------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user