-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable tokio io driver #171
Conversation
This has come up a couple of times in the past. We intentionally don't enable io to avoid confusion between tokio::net and turmoil::net types. Can I ask why you aren't using turmoil::net types in your tests and for a little more information about your use case? |
We certainly understand this intention. We have currently two use-cases, that use the tokio io types:
Maybe a compromise could be to hide the IO driver activation behind a feature flag?! |
Interesting! I'd love to hear more about this or see a demo.
This should be fine if you use tokio fs as that doesn't use the io reactor.
I'd be more comfortable doing it like this. |
You could also smuggle messages out via a channel and then run your socket independently of turmoil. |
This of course could also be possible. |
I ask the college again on his problems and I misunderstood him. The problem weren't the files, but he ran a command which uses pipes internally. And this led to a tokio crash without IO feature activated. |
If it unblocks you and it isn't too much of a hassle I'd prefer that approach. One reason for this is that at some point down the line we'd like to incorporate this into tokio itself, at which point you'd set a flag on the runtime and you get one or the other. I'm not sure when that will be, but if we can avoid it now that would save you some upgrade headache later. |
I talked to all my colleges, that are involved in this issue of needing IO within unit tests, and the consensus was, that by not using the tokio IO driver the short and medium term effort is to high and our code base readability decreases massively.
|
Let's do a Builder option and proceed with enabling it. This has the advantage of being very explicit and allows for tests to have it on and off in the same crate. |
Not completely sure about everything, e.g., building no_software runtime with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good! A couple minor comments.
src/rt.rs
Outdated
@@ -48,14 +51,17 @@ pub(crate) struct Rt<'a> { | |||
/// Optional handle to a host's software. When software finishes, the handle is | |||
/// consumed to check for error, which is propagated up to fail the simulation. | |||
handle: Option<JoinHandle<Result>>, | |||
|
|||
/// Configuration of simulation | |||
sim_cfg: Config, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you switch to just the enable_io boolean here you don't need to worry about a default cfg for the no software case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this in the recent changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry. I completely misunderstood your comment 🤦
But now, after reading it again of course I will change this appropriately.
Sorry again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm!
Merged. I will release this by eow. |
thx for your work |
Pull request includes: