Skip to main content

std_native_table

Function std_native_table 

Source
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 43)
40fn main() {
41    let rt = match Runtime::with_natives_and_config(
42        ping_pong_chunk(),
43        std_native_table(),
44        RuntimeConfig {
45            workers: 1,
46            quantum: DEFAULT_QUANTUM,
47            mailbox: MailboxConfig::DEFAULT,
48            ..Default::default()
49        },
50    ) {
51        Ok(rt) => rt,
52        Err(e) => {
53            eprintln!("runtime: {e}");
54            std::process::exit(1);
55        }
56    };
57    let Some(main_fn) = rt.function_index("main") else {
58        eprintln!("missing main");
59        std::process::exit(1);
60    };
61    let handle = match rt.spawn(main_fn, &[]) {
62        Ok(h) => h,
63        Err(e) => {
64            eprintln!("spawn: {e}");
65            std::process::exit(1);
66        }
67    };
68    let outcome = handle.join();
69    let metrics = rt.metrics();
70    rt.shutdown();
71
72    match outcome {
73        FlowOutcome::Completed(Value::Int(2)) => {
74            println!("pong replied 2 (Atomic Hop)");
75            println!("{metrics}");
76        }
77        other => {
78            eprintln!("unexpected {other:?}");
79            std::process::exit(1);
80        }
81    }
82}
More examples
Hide additional examples
examples/atomic_actors.rs (line 75)
72fn main() {
73    let rt = match Runtime::with_natives_and_config(
74        atomic_actors_chunk(),
75        std_native_table(),
76        RuntimeConfig {
77            workers: 2,
78            quantum: DEFAULT_QUANTUM,
79            mailbox: MailboxConfig::DEFAULT,
80            ..Default::default()
81        },
82    ) {
83        Ok(rt) => rt,
84        Err(e) => {
85            eprintln!("runtime: {e}");
86            std::process::exit(1);
87        }
88    };
89    let Some(main_fn) = rt.function_index("main") else {
90        eprintln!("missing main");
91        std::process::exit(1);
92    };
93    let handle = match rt.spawn(main_fn, &[]) {
94        Ok(h) => h,
95        Err(e) => {
96            eprintln!("spawn: {e}");
97            std::process::exit(1);
98        }
99    };
100    let outcome = handle.join();
101    let metrics = rt.metrics();
102    rt.shutdown();
103
104    match outcome {
105        FlowOutcome::Completed(Value::Int(72)) => {
106            println!("atomic actors ok: two clients × 8 Ask = 72");
107            println!("{metrics}");
108        }
109        other => {
110            eprintln!("unexpected {other:?}");
111            std::process::exit(1);
112        }
113    }
114}