pub fn std_native_table() -> Arc<NativeTable> ⓘExpand description
Default FFI table with StdoutSink. Prefer std_native_table_with
in embedders that must not touch stdout.
Examples found in repository?
examples/ping_pong.rs (line 13)
9fn main() {
10 let chunk = samples::ping_pong();
11 let rt = match Runtime::with_natives_and_config(
12 chunk,
13 std_native_table(),
14 RuntimeConfig {
15 workers: 1,
16 quantum: 10_000,
17 mailbox: byteflow::MailboxConfig::DEFAULT,
18 ..Default::default()
19 },
20 ) {
21 Ok(rt) => rt,
22 Err(e) => {
23 eprintln!("runtime: {e}");
24 std::process::exit(1);
25 }
26 };
27 let Some(main) = rt.function_index("main") else {
28 eprintln!("missing main");
29 std::process::exit(1);
30 };
31 let handle = match rt.spawn(main, &[]) {
32 Ok(h) => h,
33 Err(e) => {
34 eprintln!("spawn: {e}");
35 std::process::exit(1);
36 }
37 };
38 let outcome = handle.join();
39 let metrics = rt.metrics();
40 rt.shutdown();
41
42 match outcome {
43 FlowOutcome::Completed(Value::Int(2)) => {
44 println!("pong replied 2 (Atomic Hop)");
45 println!("{metrics}");
46 }
47 other => {
48 eprintln!("unexpected {other:?}");
49 std::process::exit(1);
50 }
51 }
52}More examples
examples/atomic_actors.rs (line 24)
20fn main() {
21 let chunk = samples::atomic_actors();
22 let rt = match Runtime::with_natives_and_config(
23 chunk,
24 std_native_table(),
25 RuntimeConfig {
26 workers: 2,
27 quantum: 10_000,
28 mailbox: byteflow::MailboxConfig::DEFAULT,
29 ..Default::default()
30 },
31 ) {
32 Ok(rt) => rt,
33 Err(e) => {
34 eprintln!("runtime: {e}");
35 std::process::exit(1);
36 }
37 };
38 let Some(main) = rt.function_index("main") else {
39 eprintln!("missing main");
40 std::process::exit(1);
41 };
42 let handle = match rt.spawn(main, &[]) {
43 Ok(h) => h,
44 Err(e) => {
45 eprintln!("spawn: {e}");
46 std::process::exit(1);
47 }
48 };
49 let outcome = handle.join();
50 let metrics = rt.metrics();
51 rt.shutdown();
52
53 match outcome {
54 FlowOutcome::Completed(Value::Int(72)) => {
55 println!("atomic actors ok: two clients × 8 Ask = 72");
56 println!("{metrics}");
57 }
58 other => {
59 eprintln!("unexpected {other:?}");
60 std::process::exit(1);
61 }
62 }
63}