1
0
forked from ROMEO/nexosim

Initial (g)RPC implementation

This commit is contained in:
Serge Barral
2024-04-25 11:12:54 +02:00
parent c984202005
commit e84e802f09
55 changed files with 5814 additions and 1996 deletions

View File

@ -2,8 +2,9 @@
use std::time::Duration;
use asynchronix::model::{Model, Output};
use asynchronix::simulation::{Address, EventStream, Mailbox, SimInit, Simulation};
use asynchronix::model::Model;
use asynchronix::ports::{EventBuffer, Output};
use asynchronix::simulation::{Address, Mailbox, SimInit, Simulation};
use asynchronix::time::MonotonicTime;
// Input-to-output pass-through model.
@ -26,12 +27,13 @@ impl<T: Clone + Send + 'static> Model for PassThroughModel<T> {}
/// output) running as fast as possible.
fn passthrough_bench<T: Clone + Send + 'static>(
t0: MonotonicTime,
) -> (Simulation, Address<PassThroughModel<T>>, EventStream<T>) {
) -> (Simulation, Address<PassThroughModel<T>>, EventBuffer<T>) {
// Bench assembly.
let mut model = PassThroughModel::new();
let mbox = Mailbox::new();
let out_stream = model.output.connect_stream().0;
let out_stream = EventBuffer::new();
model.output.connect_sink(&out_stream);
let addr = mbox.address();
let simu = SimInit::new().add_model(model, mbox).init(t0);
@ -243,18 +245,20 @@ fn timestamp_bench(
) -> (
Simulation,
Address<TimestampModel>,
EventStream<(Instant, SystemTime)>,
EventBuffer<(Instant, SystemTime)>,
) {
// Bench assembly.
let mut model = TimestampModel::default();
let mbox = Mailbox::new();
let stamp_stream = model.stamp.connect_stream().0;
let stamp_stream = EventBuffer::new();
model.stamp.connect_sink(&stamp_stream);
let addr = mbox.address();
let simu = SimInit::new()
.add_model(model, mbox)
.init_with_clock(t0, clock);
.set_clock(clock)
.init(t0);
(simu, addr, stamp_stream)
}