Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrent ByteString or Text readers or builders #6

Open
jberryman opened this issue Jul 14, 2014 · 1 comment
Open

Concurrent ByteString or Text readers or builders #6

jberryman opened this issue Jul 14, 2014 · 1 comment

Comments

@jberryman
Copy link
Owner

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:

  • a concurrent builder for Text, something like:

    new :: IO (InTextChan , Lazy.Text)
    write :: String -> InTextChan -> IO ()
    
  • something similar for ByteString (is there a class for types convertable to ByteString?)

  • concurrent Text and/or ByteString readers, something like:

    reader :: Text -> IO TextReader
    takeText :: Int -> TextReader -> IO Text
    
  • functions like the above but where the inputs are already Text. This case would involve efficient memory copies into the unagi array; I'm not sure if this makes more or less sense than functions describes above which would convert and write directly into the unagi array.

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

@jberryman
Copy link
Owner Author

(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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant