镜像自: https://github.com/DragonOS-Community/thingbuf.git
|
vor 3 Jahren | |
---|---|---|
.github | vor 3 Jahren | |
bench | vor 3 Jahren | |
bin | vor 3 Jahren | |
src | vor 3 Jahren | |
tests | vor 3 Jahren | |
.envrc | vor 3 Jahren | |
.gitignore | vor 3 Jahren | |
Cargo.toml | vor 3 Jahren | |
README.md | vor 3 Jahren | |
default.nix | vor 3 Jahren | |
shell.nix | vor 3 Jahren |
A: For tracing
, I wanted to be able to send formatted log lines to a
dedicated worker thread that writes them to a file. Right now, we do this
using crossbeam-channel
. However, this has the sad disadvantage that we have
to allocate String
s, send them through the channel to the writer, and
immediately drop them. It would be nice to do this while reusing those
allocations. Thus...StringBuf
.
A: Extremely.
A: As long as you don't use the APIs that wait :)
A: Because unbounded queues are of the Devil.
A: If you use it wrong, yes.
A: Originally, I imagined it as a kind of ring buffer, so (as a pun on "ringbuf"), I called it "stringbuf". Then, I realized you could do this with more than just strings. In fact, it can be generalized to arbitrary...things. So, "thingbuf".