-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mechanism to deal with server events
- Loading branch information
Showing
5 changed files
with
67 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use std::sync::Mutex; | ||
|
||
#[derive(Debug, PartialEq, Eq, Clone)] | ||
pub enum Event { | ||
WorkspaceChanged, | ||
} | ||
|
||
#[derive(Debug, Default)] | ||
pub struct EventManager { | ||
events: Mutex<Vec<Event>>, | ||
} | ||
|
||
impl EventManager { | ||
pub fn push(&self, event: Event) { | ||
let mut events = self.events.lock().unwrap(); | ||
events.push(event); | ||
} | ||
|
||
pub fn take(&self) -> Vec<Event> { | ||
let mut events = self.events.lock().unwrap(); | ||
std::mem::replace(&mut *events, Vec::new()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters