chromedriver_api/session/
manager.rs

1// use crate::prelude::*;
2use atomic_state::AtomFlag;
3
4/// The session task manager
5#[derive(Clone)]
6pub struct SessionManager {
7    flag: AtomFlag,
8}
9
10impl SessionManager {
11    /// Creates a new session task manager
12    pub fn new() -> Self {
13        Self {
14            flag: AtomFlag::new(false),
15        }
16    }
17
18    /// Locking tasks execution
19    pub async fn lock(&self) {
20        self.flag.swap(true).await;
21    }
22
23    /// Unlocking tasks execution
24    pub async fn unlock(&self) {
25        if self.flag.get() == false { return; }
26        self.flag.swap(false).await;
27    }
28}