-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Support a writer that streams the eventlog to an in-memory buffer. This is somewhat complicated, and should perhaps be migrated into its own package. @dcoutts sketched out the following possible design:
The problem will be blocking. To stream the eventlog to the same process you need non-blocking writes. If the RTS blocks trying to write data then it cannot wake up to run the Haskell code and thus you deadlock. You cannot use a pipe since that's bounded, and hence blocking.
You can write C code that uses the RTS functions to allocate an MVar pointing to a byte array and the next entry, and make a MVar based linked list as a queue. Use an empty MVar as the end of the queue. There are RTS C API functions for allocating and for writing to an MVar in a non-blocking way from C code.