diff options
author | Aram Drevekenin <aram@poor.dev> | 2023-11-10 14:16:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 14:16:02 +0100 |
commit | 3b4a355f0d6e4e73874fd7081f7d467e8b4220ba (patch) | |
tree | 488b97ae8dddecc5b54a2065de462af8636b642c /zellij-server/src/background_jobs.rs | |
parent | e55cd36b537c3f3998591f23ba66cccb472a6e3d (diff) |
feat(config): add serialization interval configuration (#2923)
* add serialization interval configuration
* fix e2e tests
* fix e2e tests
Diffstat (limited to 'zellij-server/src/background_jobs.rs')
-rw-r--r-- | zellij-server/src/background_jobs.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/zellij-server/src/background_jobs.rs b/zellij-server/src/background_jobs.rs index 5fa6ffcb5..47d281f5b 100644 --- a/zellij-server/src/background_jobs.rs +++ b/zellij-server/src/background_jobs.rs @@ -78,15 +78,20 @@ impl From<&BackgroundJob> for BackgroundJobContext { static FLASH_DURATION_MS: u64 = 1000; static PLUGIN_ANIMATION_OFFSET_DURATION_MD: u64 = 500; -static SESSION_READ_DURATION: u64 = 1000; +static SESSION_READ_DURATION: u64 = 60000; -pub(crate) fn background_jobs_main(bus: Bus<BackgroundJob>) -> Result<()> { +pub(crate) fn background_jobs_main( + bus: Bus<BackgroundJob>, + serialization_interval: Option<u64>, +) -> Result<()> { let err_context = || "failed to write to pty".to_string(); let mut running_jobs: HashMap<BackgroundJob, Instant> = HashMap::new(); let mut loading_plugins: HashMap<u32, Arc<AtomicBool>> = HashMap::new(); // u32 - plugin_id let current_session_name = Arc::new(Mutex::new(String::default())); let current_session_info = Arc::new(Mutex::new(SessionInfo::default())); let current_session_layout = Arc::new(Mutex::new((String::new(), BTreeMap::new()))); + let serialization_interval = serialization_interval.map(|s| s * 1000); // convert to + // milliseconds loop { let (event, mut err_ctx) = bus.recv().with_context(err_context)?; @@ -181,8 +186,10 @@ pub(crate) fn background_jobs_main(bus: Bus<BackgroundJob>) -> Result<()> { resurrectable_sessions, )); let _ = senders.send_to_screen(ScreenInstruction::DumpLayoutToHd); - task::sleep(std::time::Duration::from_millis(SESSION_READ_DURATION)) - .await; + task::sleep(std::time::Duration::from_millis( + serialization_interval.unwrap_or(SESSION_READ_DURATION), + )) + .await; } } }); |