Beej Jorgensen@lemmy.sdf.org to Programming@programming.dev · 18 hours agoUsing black magic to make a fast circular buffer.lo.calho.stexternal-linkmessage-square3fedilinkarrow-up120arrow-down10file-textcross-posted to: programminghackernews@lemmy.bestiver.se
arrow-up120arrow-down1external-linkUsing black magic to make a fast circular buffer.lo.calho.stBeej Jorgensen@lemmy.sdf.org to Programming@programming.dev · 18 hours agomessage-square3fedilinkfile-textcross-posted to: programminghackernews@lemmy.bestiver.se
minus-squareTechnus@lemmy.ziplinkfedilinkarrow-up4·18 hours 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