Beej Jorgensen@lemmy.sdf.org to Programming@programming.dev · 4 days agoUsing black magic to make a fast circular buffer.lo.calho.stexternal-linkmessage-square3fedilinkarrow-up123arrow-down10file-text
arrow-up123arrow-down1external-linkUsing black magic to make a fast circular buffer.lo.calho.stBeej Jorgensen@lemmy.sdf.org to Programming@programming.dev · 4 days agomessage-square3fedilinkfile-text
minus-squareTechnus@lemmy.ziplinkfedilinkarrow-up4·4 days agoThis is a neat trick but it works best on Linux and maybe macOS. Implementing it on Windows requires some luck as you can’t just map adjacent pages, you have to just request two of them and hope the OS gives you two contiguous ones. For example, see this abandoned Rust crate: https://github.com/gnzlbg/slice_deque/blob/045fb28701d3b674b5da413266ca84b3e5a70190/src/mirrored/winapi.rs#L57
This is a neat trick but it works best on Linux and maybe macOS.
Implementing it on Windows requires some luck as you can’t just map adjacent pages, you have to just request two of them and hope the OS gives you two contiguous ones. For example, see this abandoned Rust crate: https://github.com/gnzlbg/slice_deque/blob/045fb28701d3b674b5da413266ca84b3e5a70190/src/mirrored/winapi.rs#L57