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

Eliza Weisman e3d6ab1a08 chore(ci): add test workflow 3 年之前
.github e3d6ab1a08 chore(ci): add test workflow 3 年之前
src 3b23f8583b feat(thingbuf): add `no_std` compatible `StaticThingBuf` (#1) 3 年之前
tests 3b23f8583b feat(thingbuf): add `no_std` compatible `StaticThingBuf` (#1) 3 年之前
.envrc 84b9ce7057 initial commit 3 年之前
.gitignore 84b9ce7057 initial commit 3 年之前
Cargo.toml 856c1f6c93 feat(StringBuf): add `StringBuf` type 3 年之前
README.md 2eaf8a022a docs(README): add a readme 3 年之前
default.nix 84b9ce7057 initial commit 3 年之前
shell.nix 84b9ce7057 initial commit 3 年之前

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.