Skip to content

Commit c944cb6

Browse files
committed
Drop &mut queue before calling API
1 parent a4fd118 commit c944cb6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

omp-gdk/src/scripting/core/events.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![allow(clippy::all)]
2+
use std::collections::VecDeque;
3+
24
use crate::{events::EventArgs, runtime::each_module, types::stringview::StringView};
35

46
#[repr(C)]
@@ -8,11 +10,12 @@ pub struct OnTickArgs {
810

911
#[no_mangle]
1012
pub unsafe extern "C" fn OMPRS_OnTick(args: *const EventArgs<OnTickArgs>) {
11-
crate::runtime::API_QUEUE.with_borrow_mut(|queue| {
12-
while let Some(api_call) = queue.pop_front() {
13-
api_call();
14-
}
15-
});
13+
let api_calls: VecDeque<_> =
14+
crate::runtime::API_QUEUE.with_borrow_mut(|queue| queue.drain(..).collect());
15+
// drop mutable reference to api queue before calling api callbacks
16+
for callback in api_calls {
17+
callback();
18+
}
1619

1720
each_module(move |mut script| {
1821
script.on_tick(*(*(*args).list).elapsed);

0 commit comments

Comments
 (0)