Conversation
Sends a message to the logging thread, then blocks until the logger acknowledges it. Contrast this to the busy-loop approach in slog-rs#36 Pinned to the branch used in PR #349, so cannot be released until that PR is accepted. Fixes issue slog-rs#35
Pinned to the branch used in slog-rs/slog#349, so that must be accepted first. The 'pretty' example is pinned to use the branch in slog-rs/async#39, so that must also be accepted first.
|
As I'm reading through it, I wonder if there might be a less code-intensive and more readable approach. How about putting some kind of backchannel into the Flush message (I'd say a semaphore with 0 tokens in it, the worker thread provides one after flushing, the caller waits for it; except there don't seem to be any semaphores in Rust 😇). That way it would be clear whose flush got satisfied, there would be less work around poisoned mutexes, etc. |
|
Increasing message size might negatively affect perf. of the main codepath. |
Thank you for the suggestion! I will look for a simpler approach.
You may be right about this, but an |
|
Idea for a simpler implementation: Use a two-way channel or queue dedicated to flushing and acknowledgment of flushing. EDIT: A zero-capacity channel may be what we want. According to
|
|
Probably a proper way to do flush ack using only stdlib is to use |
This is similar to what I am doing right now, using an enum for the state. Your version is better since the enum currently doesn't have a stamp and blocks if there is an existing flush rather than queuing it. I also suspect your idea would be simpler to implement. |
This will be subsumed by a proper upgrade to v2.8. For the time being, this makes it easier to test things out.
Sends a message to the logging thread, then blocks until the logger acknowledges it.
Contrast this to the busy-loop approach in #36
Pinned to the branch used in PR slog-rs/slog#349, so cannot be released until that PR is accepted.
Fixes issue #35