[darcs-devel] http pipelining

Stefan O'Rear stefanor at cox.net
Tue Dec 18 21:29:26 UTC 2007


On Tue, Dec 18, 2007 at 09:51:02AM +0000, Simon Marlow wrote:
> Stefan O'Rear wrote:
>
>> How about something like:
>>
>> data Cookie = C { getData :: L.ByteString }
>> fetchURL :: URI -> Cookie           -- sends request when forced, reads responce when deeply forced
>>
>> {- sample implementation, ignores the existance of multiple servers and
>> the Connection: close header -}
>>
>> sock = unsafePerformIO ...
>>
>> queue fun = newChan >>= \q -> forkIO (forever (readChan q >>= fun)) >>
>>             return q
>>
>> writer = unsafePeformIO $ queue $ \ req -> writeRequest sock req
>> reader = unsafePeformIO $ queue $ \ var ->
>>   readRequest sock (\ bit -> writeChan var (Just bit)) >>
>>   writeChan var Nothing
>>
>>
>> fetchURL url = unsafePerformIO $ do
>>   c <- newChan
>>   writeChan writer (fetch url)
>>   writeChan reader c
>
> A single queue seems nicer, given that you would otherwise need some 
> locking to prevent races between multiple threads (I know this doesn't 
> apply to darcs, but still).

The code was intended only to clarify the semantics of the interface.

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.osuosl.org/pipermail/darcs-devel/attachments/20071218/bc5c2b76/attachment.pgp 


More information about the darcs-devel mailing list