jberryman / unagi-chan

A haskell library implementing fast and scalable concurrent queues for x86, with a Chan-like API
BSD 3-Clause "New" or "Revised" License
127 stars 15 forks source link

Concurrent ByteString or Text readers or builders #6

Open jberryman opened 10 years ago

jberryman commented 10 years ago

Unagi.Unboxed could be modified fairly easily to use a payload that matches the internals of either Text or ByteString. I'm a little bit sketchy on details but this could accommodate some pretty interesting and very efficient functions, like:

Please comment with your particular use case if you need something like these.

jberryman commented 9 years ago

(is there a class for types convertable to ByteString?)

So what this is almost just Builder, where we could use a BufferWriter to write the buffer to our array, for an interface like:

writeChan :: ChanBytesString -> Builder -> IO ()

The only issue though is that we want (an O(1), preferably) function:

builderLength :: Builder -> Int

i.e. the amount of allocation needs to be statically known (so we know how much to increment our counters).

I think this requires a new library, but buffer-builder seems to be almost there already, and would at least be a good place to start a fork if the required changes aren't possible.