-
Notifications
You must be signed in to change notification settings - Fork 18
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
Print immediately from a LogSender if read_line() call is not in progress #30
Comments
Do you want to have a global output point in |
Is there a non-racy way to solve this use-case without cooperation from |
I am currently working on a refactor that would make |
You definitely have to use When I believe the best way to solve the problem is making And probably we should use |
Yea, a simple |
The changes described in my previous comment have now been implemented: The |
This is again because I'm making a
log
logger that outputs without messing uplinefeed
, and would also be a breaking change.Since
LogSender
writes only actually get written duringread_line
, something like the following has unintuitive (albeit documented) behavior:One would expect that the output would look like:
But instead, you get:
since the LogSender-sent messages aren't printed until the next call to
read_line
.Something (that I now realize won't work) would be to change the
_send_counter
inLogSender
to beArc<Mutex<()>>
, and lock it whenever inread_line
or printing directly fromLogSender
? Then ifLogSender
can't lock it, it'll send the messages via the channel.There's a data race there, though, if
Reader
has the lock,LogSender
checks for the lock and fails to acquire it, andReader
drops it and exits beforeLogSender
finishes sending the message on theSender<String>
. If you can think of a way to implement this that doesn't have the race, I'd be happy to write the actual code.The text was updated successfully, but these errors were encountered: