kinghajj / deque

A (mostly) lock-free concurrent work-stealing deque in Rust.
Other
232 stars 24 forks source link

Removed dep on alloc #3

Closed faern closed 9 years ago

faern commented 9 years ago

I wanted to remove the dependency to alloc since it's not allowed in beta. I replaced it with allocating a vector and taking an unsafe pointer into it. On drop I recreate a slice from that pointer and let it drop in the normal Rust way.

WARNING: I'm far from 100% sure this works the way I intend it to. I'm not totally sure what I have done here, but the tests seem to work. I have run both the tests in deque and in my projects depending on deque without problems.

faern commented 9 years ago

I just realized the drop only drops the reference to the newly constructed slice. It never deallocates it. If I'm right then this PR introduces a memory leak.

kinghajj commented 9 years ago

Since thread::scoped is now behind a feature gate until that problem gets resolved, I'm not in a rush to remove unstable dependencies yet. I'd also rather not abuse Vec to get around the lack of a stable allocation API, which should be available by 1.0.