Best way to get to CAS/fetch-and-add on unboxed vectors?
rrnewton at gmail.com
Wed Nov 20 15:06:08 UTC 2013
Since GHC 7.8 will now absorb the functionality that was previously only in
the atomic-primops package<http://hackage.haskell.org/package/atomic-primops>,
it would be great to start exposing this for the data structures people
actually want to use: i.e. unboxed vectors rather than raw
I've been reading through the code of vector, thinking that I would release
some kind of "vector-atomics" package. Alas, I don't see how that is
possible. There's no way to get at the MutableByteArray associated with an
(1) I think the minimum that would be necessary would be to modify
"Data/Vector/Unboxed/Base.hs", where the instances for the type family
actually exist, to provide an additional instance for each "MVector s Foo"
that records the fact that the vector has and can expose a
(2) Alternatively, an "exposeMutableByteArray" function could be added to
the existing Unbox class. But this would affect other third party Unbox
instances out there in the world... Is there any interest insupporting
Unbox instances that are NOT implemented as a MutableByteArray?
(3) The most invasive (but best for the user) change would be to extend the
basic MVector interface to include notions of concurrency-related
operations right inside the vector package (CAS, etc). But they should
still probably go in a separate class (not class MVector), just because
they will be specific to Unboxed and Storable vectors rather than boxed
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries