Opened 13 years ago

Closed 9 years ago

#1070 closed feature request (fixed)

Add hPutNonBlocking to Data.ByteString

Reported by: guest Owned by: duncan
Priority: high Milestone: 7.2.1
Component: libraries (other) Version: 6.6
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


This patch adds the function hPutNonBlocking, which is a non blocking version of hPut. The change is completely analogous to the hGet/hGetNonBlocking functions.

Attachments (1)

hPutNonBlocking.darcs.patch (43.3 KB) - added by guest 13 years ago.

Download all attachments as: .zip

Change History (8)

Changed 13 years ago by guest

Attachment: hPutNonBlocking.darcs.patch added

comment:1 Changed 13 years ago by igloo

Milestone: Not GHC

comment:2 Changed 13 years ago by duncan

One problem with this patch is that it makes the type of hPutNonBlocking different for GHC vs non-GHC. It's not clear to me what the right API should be either. I presume it currently returns the number of bytes written, and you need to check that to see if the write completed sucessfully or if there's more left to write. Perhaps the right api would be more like:

hPutNonBlocking :: Handle -> ByteString -> IO (Maybe ByteString)

So if it returns Nothing you know it wrote it all, otherwise it returns the remainder of the buffer that it did not manage to write (which may be the whole original input or some tail of it).

comment:3 Changed 12 years ago by igloo

Component: libraries/baselibraries (other)
Type: proposalfeature request

comment:4 Changed 11 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:5 Changed 11 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:6 Changed 9 years ago by igloo

Milestone: Not GHC7.2.1
Owner: set to duncan
Priority: normalhigh
Type of failure: None/Unknown

Duncan, we should work out what should be done with this. Should we just close it? Or will it be implemented?

comment:7 Changed 9 years ago by duncan

Resolution: fixed
Status: newclosed

I have decided to add the function with this type:

hPutNonBlocking :: Handle -> ByteString -> IO ByteString

That is, it returns the unwritten tail, if any. This generalised better to the lazy bytestring case. In the lazy bytestring case, using the number of bytes written would mean that any correct program would necessarily have a space leak.

This change is now in the upstream darcs repo and will be in bytestring- which will be released soonish.

Note: See TracTickets for help on using tickets.