1
0
mirror of https://github.com/danog/byte-stream.git synced 2024-11-30 04:19:23 +01:00
Commit Graph

31 Commits

Author SHA1 Message Date
Gabriel Ostrolucký
d5cd42a765 Add chunksize setter to Resource*Stream classes (#55)
Fixes #50.
2019-03-31 16:51:36 +02:00
Niklas Keller
3a4e493d39 Change #47 test case 2018-12-25 13:13:28 +01:00
Niklas Keller
d161589772 Apply PSR-2 2018-09-22 16:04:00 +02:00
Niklas Keller
9f60974881 Fix resource input streams
The read watcher needs to be disabled now, because immediate reads will process the next immediate read now in the next tick.

Fixes #38.
2018-03-11 10:19:43 +01:00
Niklas Keller
062f16d0c5 Defer immediate reads
Immediate reads have been introduced to support in-memory streams and STDIN on Windows, but this causes problems during piping of streams that always have data available, because it blocks everything else. This is resolved by deferring the promise resolution to the next tick.
2018-03-09 17:40:36 +01:00
Niklas Keller
a4739c8a6d Attempt direct read on ResourceInputStream::read()
This change should resolve the low performance on Windows' STDIN. STDIN
on Windows is a file handle and Windows has specialized support built
into it's stream_select implementation, but a stream_select with a file
handle takes 100ms, which results in slow performance if we read in
smaller chunks and always have to wait 100ms between these.

Fixes amphp/socket#52.
2018-03-08 11:38:16 +01:00
Niklas Keller
0b6d99b2c3 Remove outdated note about closing ResourceInputStreams 2017-12-27 20:13:24 +01:00
Niklas Keller
0c059ba0e6 Suppress errors also for stream_socket_shutdown, relates to #32 2017-12-10 17:40:58 +01:00
Niklas Keller
c5e31aa7b7 Fix #32: Suppress errors for feof, because pthreads 2017-12-10 17:36:05 +01:00
Niklas Keller
3c24903849 Use fread() for STDIO instead of stream_get_contents()
Turns out this fixes the issues with amphp/parallel on Windows.
2017-12-05 19:57:30 +01:00
Bob Weinand
0f501deb7c Fix #29 - do not release resource on __destruct()
This ensures getResource() still returning a valid resource during cyclic garbage collection
2017-10-17 03:50:40 +02:00
Niklas Keller
d60ba033c4 Use stream_get_contents instead of fread for ResourceInputStream
This fixes an issue with TLS streams: https://github.com/amphp/artax/issues/138.

We still use  for UDP, because stream_get_contents might read multiple packages there if I'm not mistaken.
2017-10-08 12:38:01 +02:00
Fabien Villepinte
0dff1fe859 Anonymous function has an unused use $resource 2017-10-01 12:04:51 +02:00
Bob Weinand
a70a650793 Also \assert() against fclose() instead of silently returning null 2017-07-15 10:38:47 +02:00
Niklas Keller
704adf70cf Add reference and unreference methods to ResourceInputStream 2017-06-23 16:33:13 +02:00
Niklas Keller
b67358ad91 Suppress errors on close for resource streams
A resource might still be non-null, but already closed.
2017-06-19 08:43:07 +02:00
Aaron Piotrowski
48c4e122d8
Tweak closing
Resource is not nulled in watcher callback if reading/writing fails so close() will still call shutdown/fclose.
2017-06-18 23:14:59 -05:00
Niklas Keller
8d74c85048 Apply same closing mechanism to RIS 2017-06-18 23:25:22 +02:00
Niklas Keller
93540890fd Remove unnecessary isset check for stream modes 2017-06-18 22:55:44 +02:00
Niklas Keller
8b20bf90b8 Fix feof check 2017-06-17 17:46:18 +02:00
Niklas Keller
2ecbf8aa8b Respect chunk size for ResourceOutputStream, document resource streams 2017-05-25 18:12:12 +02:00
Niklas Keller
eb9394a5da Make resource streams final 2017-05-22 14:38:39 +02:00
Aaron Piotrowski
ca3ab2dc73 Restore destructor on resource stream
Forgot close() needed to be called to free watcher.
2017-05-12 10:27:58 -05:00
Aaron Piotrowski
e7f7326363 PendingReadException → PendingReadError
Consecutive reads is a coding error, so it should be an instance of Error.
2017-05-12 00:06:07 -05:00
Aaron Piotrowski
f6e765cea3 Succeed reads with null on closed stream 2017-05-11 23:56:36 -05:00
Aaron Piotrowski
c2eac67b79 Fix close() and make public again 2017-05-11 23:52:15 -05:00
Aaron Piotrowski
cfbf25e3b5 Remove close() from interfaces 2017-05-11 18:08:45 -05:00
Niklas Keller
55a7118da9 Add .editorconfig and fix code style 2017-05-07 22:14:45 +02:00
Niklas Keller
73e6441fd9 Add getResource() to resource streams 2017-05-05 16:45:53 +02:00
Aaron Piotrowski
4b7a537d7b Refactor ResourceInputStream for new API 2017-05-04 16:30:40 -05:00
Niklas Keller
bf90335bb6 Major API change + merged Reader and Writer from amphp/socket 2017-04-30 08:33:16 +02:00