1
0
forked from ROMEO/nexosim

89 Commits

Author SHA1 Message Date
Serge Barral
84ad02a248 Make the gRPC init more general
Instead of producing a SimInit object, a bench is now expected to return
a fully constructed simulation with its scheduler.

This means that the client does not necessarily need to provide the
starting time for the simulation. This start time may be hardcoded in
the bench, or may be taken as a parameter for the bench configuration.

This change make it possible for benches to do more, for instance to
pre-schedule some events, or to do less, for instance by hardcoding the
simulation time rather than accept an arbitrary simulation time.
2024-11-15 23:23:17 +01:00
Serge Barral
3c1056d699 Remove the LineId API
This was probably never used.
2024-11-15 17:15:25 +01:00
Serge Barral
0f1d876aed Return both simulation and scheduler at init 2024-11-15 16:52:24 +01:00
Serge Barral
f4686af49a Finalize the Context and BuildContext API
The API style is now more uniform: both are passed by mutable ref, and
only expose accessors. Additionally, the methods that were initially
accessed through the scheduler field are now directly implemented on
`Context`.
2024-11-15 16:12:07 +01:00
Serge Barral
b1896dbde9 Order scheduled messages by their origin
Previously, the scheduler key used the target model as subkey to order
messages that target the same model.

Now this subkey is the origin model rather than the target, or in the
case of the global scheduler, 0. This doesn't change anythin in practice
for the local scheduler since the origin and target models were the
same, but for the global scheduler this provides additional guarranties.

For instance, if the global scheduler is used to schedule an event
targetting model A and then an event targetting model B where the latter
triggers a message to A, it is now guarranteed that the first message
will get to A before the second.
2024-11-15 14:39:51 +01:00
Serge Barral
b5aea810ae Merge step_by and step_until into a unique method
Now that `step_by` returns an error anyway (it was unfaillible before),
there is no more incentive to keep it as a separate method.
The `step_until` method now accepts an `impl Deadline`, which covers
both cases (`Duration` and `MonotonicTime`).
2024-11-14 17:01:33 +01:00
Jaŭhien Piatlicki
1af4de1832 Remove println from examples 2024-11-13 23:59:50 +01:00
Serge Barral
ba1e668447 Report panics as errors + identify panicking model
The build context is now passed as a mutable reference due to the need
to mutate data when adding a model.

Contains small unrelated cleanups and documentation improvements too.
2024-11-13 19:40:58 +01:00
Serge Barral
49e713262b Check clock sync with configurable tolerance 2024-11-12 11:34:17 +01:00
Serge Barral
e6901386cf Add support for simulation timeouts 2024-11-09 12:17:27 +01:00
Serge Barral
abbfb64628 Run integration tests on both ST and MT executors 2024-11-08 11:08:47 +01:00
Jauhien Piatlicki
35e7e17814
Merge pull request #54 from asynchronics/feature/protomodel
Introduce ProtoModel trait, remove Model::setup
2024-11-05 23:36:51 +01:00
Serge Barral
039fefad47 Introduce ProtoModel trait, remove Model::setup
The external_input example has been as well adapted and (at least
temporarily) simplifiedi/modified to remove the dependencies on
`atomic_wait` and `mio`.
2024-11-05 16:16:42 +01:00
Jaŭhien Piatlicki
634614a2a1 Add observable states utility 2024-10-31 14:43:30 +01:00
Serge Barral
e7b64524e0 Report deadlocked models and their malbox size 2024-10-28 12:25:02 +01:00
Serge Barral
1cfaa00f9e Make execution failible, impl deadlock detection
TODO: return the list of models involved in a deadlock.

Note that Many execution errors are not implemented at all at the
moment and will need separate PRs, namely:
- Terminated
- ModelError
- Panic
2024-10-20 12:35:44 +02:00
SMassalski
ef17e56b10 Fix missing derive clone statement for Requestor 2024-10-17 16:20:44 +02:00
Serge Barral
1dfb79f596 Add small example of tracing logging 2024-09-13 16:08:49 +02:00
Serge Barral
7487a264ab Add tracing support for simulation timestamps 2024-09-12 15:35:31 +02:00
Serge Barral
e376f17c7c Add model tracing spans + tracing feature flag 2024-09-10 11:12:49 +02:00
Serge Barral
b500d071ec Upgrade some dependencies 2024-09-08 23:21:32 +02:00
Serge Barral
2a8a3738cb Use better supported UTF symbols for arrow heads 2024-09-08 17:38:58 +02:00
Serge Barral
1c0c8ed529 Add automatic feature documentation for docs.rs 2024-09-08 17:31:39 +02:00
Serge Barral
6b43fcf704 Simplify gRPC backend arch + remove wasm backend 2024-09-08 17:03:56 +02:00
Serge Barral
114c148114 Move loom as a dev-dependency 2024-09-07 19:53:30 +02:00
Serge Barral
1b1db5e0b8 Take message ref in (filter)map_connect closures
This avoids preemptive cloning when the closures don't consume the
message, which is common when the filtering closure returns `None`.
2024-08-16 11:15:58 +02:00
Serge Barral
525f708d55 Add tests for filter_map_connect (source & output) 2024-08-07 17:36:51 +02:00
Serge Barral
c4d93f5c31 Disable Loom tests for broadcaster due to Loom bug 2024-08-07 10:29:13 +02:00
Serge Barral
b544bcee92 Simplify task_set & satisfy clippy 2024-08-07 10:23:10 +02:00
Serge Barral
b5187ded44 Optimize filtered connections from outputs 2024-08-07 10:11:53 +02:00
Serge Barral
2270a94b8d Simplify output broadcaster implementation 2024-08-05 09:56:13 +02:00
Serge Barral
7f244d2334 Add map/filter_map variants for source connection 2024-08-05 09:11:51 +02:00
Serge Barral
3527d62b41 Remove unnecessary trait bounds + improve doc 2024-08-03 19:29:29 +02:00
Serge Barral
0ec781e18b Add filter_map variants for output port connection 2024-08-03 11:47:57 +02:00
Serge Barral
9a2cfe8e77 Add support for mapped connections from ports 2024-08-02 18:53:07 +02:00
Jaŭhien Piatlicki
3b4a3e9b0e More idiomatic loop 2024-08-02 16:19:36 +02:00
Jaŭhien Piatlicki
5d61abd729 Fix method visibility 2024-08-02 16:13:21 +02:00
Jaŭhien Piatlicki
6e3d5bb132 Change scheduler interface and add external inputs example.
Relevant for issue #13.
2024-08-02 14:06:49 +02:00
Serge Barral
a6a2c85129
Merge pull request #29 from asynchronics/feature/grpc-init-parameters
Accept an arbitrary argument for remote init
2024-07-31 16:00:29 +02:00
Serge Barral
1b0395f693 Accept an arbitrary argument for remote init 2024-07-29 18:41:25 +02:00
Jaŭhien Piatlicki
8b015b2eba Add AutoActionKey 2024-06-26 13:42:24 +02:00
Serge Barral
8ec5cd9e9b Replace MessagePack by CBOR
CBOR looks very similar but seems more future-proof as it was
standardized by the IETF in RFC 8949.
2024-06-19 12:00:59 +02:00
Serge Barral
0abc520e4b Split sinks and source registries
This makes it possible to concurrently control and monitor the
simulation when using gRPC.
Accordingly, the gRPC server now runs on 2 threads so it can serve
control and monitoring requests concurrently.
2024-06-12 11:20:34 +02:00
Serge Barral
f731d40add WIP 2024-06-11 11:27:16 +02:00
Serge Barral
59d2af51ba Expose the Protobuf simulation service to WASM/JS 2024-05-27 23:33:02 +02:00
Serge Barral
77e6e569ff Add same-thread executor support 2024-05-27 23:12:45 +02:00
Jaŭhien Piatlicki
195bcdceba Add instance name to model contexts 2024-05-10 14:32:07 +02:00
Jaŭhien Piatlicki
02eec1b277 Add test and improve example 2024-05-08 11:20:33 +02:00
Serge Barral
2fa159a87f Fix comments 2024-05-07 12:44:42 +02:00
Serge Barral
af3d68e76f Force the waker VTable to be uniquely instantiated
From Rust 1.78, `Waker::will_wake` tests equality by comparing the VTable
pointers rather than the content of the VTable.

Unfortunately, this exposes some instability in the code generation
which sometimes causes several VTables to be instantiated in memory for
the same generic parameters. This can in turn defeat `Waker::will_wake`
if e.g. `Waker::clone` and `Waker::wake_by_*` end up with different
pointers.

The problemt is hopefully addressed by preventing inlining of the VTable
generation function. A test has been added to try to detect regression,
though the test may not be 100% reliable.
2024-05-07 01:37:47 +02:00