open_entry_bindings/
extensions.rs1use std::{collections::{HashMap, hash_map::{Values, Iter}}, sync::Arc};
2
3use libloading::Library;
4
5use crate::{virtual_thread::VThread, executor::{Lock, ExecutorBehaviour}, event::EventType, runtime::Runtime};
6
7pub struct Extensions(HashMap<u32, Arc<Extension>>);
8
9impl Extensions {
10 #[inline(always)] pub fn iter(&self) -> Values<'_, u32, Arc<Extension>> {
11 unsafe { crate::Extensions__iter.unwrap_unchecked()(self) }
12 }
13
14 #[inline(always)] pub fn all(&self) -> Iter<'_, u32, Arc<Extension>> {
15 unsafe { crate::Extensions__all.unwrap_unchecked()(self) }
16 }
17
18 #[inline(always)] pub fn get(&self, id: u32) -> Arc<Extension> {
19 unsafe { crate::Extensions__get.unwrap_unchecked()(self, id) }
20 }
21}
22
23pub struct Extension {
24 _lib: Library,
25 _env_fn: Option<usize>, _envj_fn: Option<usize>, _event: usize, _init: usize, }
30
31impl Extension {
32 #[inline(always)] pub fn function_call(&self, vthread: VThread, lock: Lock, id: u32, drop: bool) -> (Lock, ExecutorBehaviour) {
33 unsafe { crate::Extension__function_call.unwrap_unchecked()(self, vthread, lock, id, drop) }
34 }
35
36 #[inline(always)] pub fn interrupt_call(&self, vthread: VThread, lock: Lock, id: u32, drop: bool) -> (Lock, ExecutorBehaviour) {
37 unsafe { crate::Extension__interrupt_call.unwrap_unchecked()(self, vthread, lock, id, drop) }
38 }
39
40 #[inline(always)] pub fn dispatch_event(&self, runtime: Arc<Runtime>, event: EventType) {
41 unsafe { crate::Extension__dispatch_event.unwrap_unchecked()(self, runtime, event) }
42 }
43}