fix, separate window, event stream leak

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow
2023-08-07 09:01:31 +08:00
parent 6111042907
commit 7dcb28ce33
8 changed files with 41 additions and 26 deletions

View File

@@ -1093,16 +1093,28 @@ pub fn push_global_event(channel: &str, event: String) -> Option<bool> {
Some(GLOBAL_EVENT_STREAM.read().unwrap().get(channel)?.add(event))
}
pub fn start_global_event_stream(s: StreamSink<String>, app_type: String) -> ResultType<()> {
if let Some(_) = GLOBAL_EVENT_STREAM
.write()
#[inline]
pub fn get_global_event_channels() -> Vec<String> {
GLOBAL_EVENT_STREAM
.read()
.unwrap()
.insert(app_type.clone(), s)
{
log::warn!(
"Global event stream of type {} is started before, but now removed",
app_type
);
.keys()
.cloned()
.collect()
}
pub fn start_global_event_stream(s: StreamSink<String>, app_type: String) -> ResultType<()> {
let app_type_values = app_type.split(",").collect::<Vec<&str>>();
let mut lock = GLOBAL_EVENT_STREAM.write().unwrap();
if !lock.contains_key(app_type_values[0]) {
lock.insert(app_type.clone(), s);
} else {
if let Some(_) = lock.insert(app_type.clone(), s) {
log::warn!(
"Global event stream of type {} is started before, but now removed",
app_type
);
}
}
Ok(())
}