-
Notifications
You must be signed in to change notification settings - Fork 9
/
engine-api.txt
65 lines (50 loc) · 2.14 KB
/
engine-api.txt
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
62
63
64
65
pub trait Engine: Decompose + Send + Vertex + Unpin + 'static {
/// Turn the Engine into an executable `Future`
fn activate<'a>(self: Pin<&'a mut Self>) -> BoxFuture<'a, EngineResult>;
/// Returns a text description of the engine.
fn description(self: Pin<&Self>) -> String;
/// Returns the progress tracker, which implies the future work.
fn tracker(self: Pin<&mut Self>) -> &mut Indicator;
/// Asks the engine to updates its local storage pointer.
///
/// # Warning
///
/// EngineLocalStorage is only accessed from a thread/runtime at a time. There should be no
/// concurrent access to it. But since Engine can be moved between Runtimes, the local storage
/// could be read from different threads _at different times_ (i.e., _Send_).
///
/// The user must ensure their storage type are _Send_.
#[inline]
fn set_els(self: Pin<&mut Self>) {
// empty default impl
}
/// Handle request sent by the network operator.
#[inline]
fn handle_request(&mut self, _request: Vec<u8>, _cred: UCred) -> Result<()> {
Ok(())
}
/// NOTE(wyj): temporary API
/// engines should not have thread/runtime local states in the fugture
/// Preform preparatory work before detaching the engine from runtime
/// e.g., clean thread-local states
#[inline]
fn pre_detach(&mut self) -> Result<()> {
// empty default impl
Ok(())
}
}
Basic
description() Returns a text description of the engine.
tracker() Returns the progress tracker, which implies the future work.
set_els() Asks the engine to updates its local storage pointer.
Elements
input/output_queue(port_number) Returns the a peer engine's queue for
receiving/sending RPC descriptors.
handle_request(bytes, user_id) Handle a control path request.
Upgrade
flush() Flushing the data and command queues.
decompose() Decompose the engines to compositional state.
restore(state) Create an engine from decomposed state.
check_compatible(v1, v2) Returns whether two version of an engine are compatible.
Future
poll() Attempt to make some progress.