镜像自: https://github.com/DragonOS-Community/thingbuf.git

Eliza Weisman c8ad71e283 test: `LOOM_LOG` support, nicer panic handling (#9) %!s(int64=3) %!d(string=hai) anos
.github 442463383d chore(ci): fix yaml mistake %!s(int64=3) %!d(string=hai) anos
benches c4ad975017 test: disable task budget in tokio mpsc benchmarks %!s(int64=3) %!d(string=hai) anos
src c8ad71e283 test: `LOOM_LOG` support, nicer panic handling (#9) %!s(int64=3) %!d(string=hai) anos
tests 38cbad2026 feat: add nicer `fmt::Debug` impls (#4) %!s(int64=3) %!d(string=hai) anos
.envrc 84b9ce7057 initial commit %!s(int64=3) %!d(string=hai) anos
.gitignore 84b9ce7057 initial commit %!s(int64=3) %!d(string=hai) anos
Cargo.toml c8ad71e283 test: `LOOM_LOG` support, nicer panic handling (#9) %!s(int64=3) %!d(string=hai) anos
README.md b990dc80cc docs: fix markdown in FAQ %!s(int64=3) %!d(string=hai) anos
default.nix 84b9ce7057 initial commit %!s(int64=3) %!d(string=hai) anos
shell.nix 84b9ce7057 initial commit %!s(int64=3) %!d(string=hai) anos

README.md

FAQs

  • Q: Why did you make this?

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 Strings, 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.

  • Q: Is it lock-free?

A: Extremely.

  • Q: Why is there only a bounded variant?

A: Because unbounded queues are of the Devil.

  • Q: Isn't this just a giant memory leak?

A: If you use it wrong, yes.

  • Q: Why is it called that?

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".

  • Q: Why don't the Ref types implement Deref and DerefMut?

A: Blame loom for this.

  • Q: Why do the channels only have try_send? Where's send?

A: I haven't written send yet. :)