Closed fredemmott closed 4 years ago
Update was cleaning up grep results for _nd
; mostly comments, but pipe_nd() too.
facebook/hhvm#8604 would be nice now :stuck_out_tongue:
$file = File\open_read_write('file.txt');
defer await $file->closeAsync();
@fredemmott merged this pull request in hhvm/hsl-experimental@9fb51de1c96cffba5d2b2bb29fb2604e9c374225.
Discussed when removing buffered operations like
readLine
; we're going to be replacing those with aBufferedReader($handle)
class or similar, so composition is going to be a key part of usage. Composition with disposables is banned, so make the API match the common case.The short version of that discussion is that combining async with buffered IO is complicated, and a strict layering makes things somewhat clearer and safer.
This also cuts the number of interfaces roughly in half.
Future work (very soon): add a disposable API for autoclose. I'm leaving that for a later PR as that's more bikesheddable.
Some options include:
getHandle
)$f = File\open_...(); using $f->scopeGuard();
Whichever we go with, I'll adjust TemporaryFile to match, but want to leave that for later diff.