tokio-rs / bytes

Utilities for working with bytes
MIT License
1.87k stars 278 forks source link

Why is the `data` pointer atomic? #623

Closed RalfJung closed 1 year ago

RalfJung commented 1 year ago

I've been trying to understand how bytes works these days, and one thing I cannot figure out is: why is the data pointer atomic? So far I've only found calls to data.load and data.with_mut, but I could not find a case where it is actually mutated while shared. Grepping for data.store comes back empty.

Darksonn commented 1 year ago

I believe it's here:

https://github.com/tokio-rs/bytes/blob/05e9d5cab95e5ce1d57dd498a9567639de50f841/src/bytes.rs#L1157-L1166

RalfJung commented 1 year ago

Ah, that's it indeed! Thanks.