1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use core::future::Future;
use crate::internal::{
base::*,
functional::*,
protocol::{
LinearToShared,
Lock,
SharedToLinear,
},
};
pub fn accept_shared_session<F>(
cont: impl Future<Output = PartialSession<(Lock<F>, ()), F::Applied>>
+ Send
+ 'static
) -> SharedSession<LinearToShared<F>>
where
F: Protocol,
F: SharedRecApp<SharedToLinear<LinearToShared<F>>>,
F::Applied: Protocol,
{
unsafe_create_shared_session(
move |receiver1: Receiver<(
SenderOnce<()>,
SenderOnce<LinearToShared<F>>,
)>| async move {
let (lock_producer_end, lock_client_end) = <Lock<F>>::create_endpoints();
let (producer_end, client_end) = F::Applied::create_endpoints();
let m_sender1 = receiver1.recv().await;
if let Some((sender5, sender6)) = m_sender1 {
sender6
.send(LinearToShared {
linear: Box::new(client_end),
})
.unwrap();
sender5.send(()).unwrap();
lock_producer_end.send(Lock { unlock: receiver1 }).unwrap();
debug!("[accept_shared_session] calling cont");
unsafe_run_session(
cont.await,
(App::new(lock_client_end), ()),
producer_end,
)
.await;
debug!("[accept_shared_session] returned from cont");
} else {
}
},
)
}