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
pub use *;
/// Runs a future to completion on the calling thread, together with zruntime.
///
/// This is for a program that has no async runtime to poll zlink's futures with: put the async
/// code in one call to it, and the call blocks the thread until the future completes.
///
/// The sockets that [`unix`] makes inside the call are on the runtime of the calling thread:
/// between polls of the future, the thread runs their I/O, so their traffic needs no other thread.
/// They work under any other executor as well: where no call to this function runs their I/O, a
/// helper thread of zruntime does. `connect_local` and `bind_local` instead require a running
/// `LocalRuntime`.
///
/// The future must not block the thread to wait for the sockets, for example by waiting
/// synchronously for a reply: their I/O runs on this same thread, between polls of the future, so
/// such a wait never ends.
///
/// # Panics
///
/// Panics if the calling thread is running zruntime already, as it is inside the future of another
/// call to this function: the inner call would wait for its own thread. Do not call it from a task
/// of another executor either: it blocks that executor's thread until the future completes, which
/// deadlocks if the future needs that thread.