scope_lock/extended/
mod.rs1use core::marker::PhantomData;
2
3pub mod func;
4pub mod future;
5pub mod sync;
6
7pub struct Extender<'scope, 'env> {
8 rc: &'scope sync::ReferenceCounter,
9 scope: PhantomData<&'scope mut &'scope ()>,
10 env: PhantomData<&'env mut &'env ()>,
11}
12
13impl<'scope, 'env> Extender<'scope, 'env> {
14 pub(crate) fn new(rc: &'scope sync::ReferenceCounter) -> Self {
15 Extender {
16 rc,
17 scope: PhantomData,
18 env: PhantomData,
19 }
20 }
21
22 pub(crate) fn guard(&'scope self) -> sync::ReferenceCounterGuard<'scope> {
23 self.rc.guard()
24 }
25
26 unsafe fn associate_reference<T>(&'scope self, inner: T) -> AssociateReference<T> {
27 AssociateReference {
28 inner,
29 _reference_guard: unsafe { self.rc.acquire() },
30 }
31 }
32}
33
34struct AssociateReference<T> {
35 inner: T,
36 _reference_guard: sync::Reference,
38}
39
40struct UnsafeAssertSync<T>(T);
41unsafe impl<T> Sync for UnsafeAssertSync<T> {}
42
43struct UnsafeAssertSend<T>(T);
44unsafe impl<T> Send for UnsafeAssertSend<T> {}