amphp / byte-stream

A non-blocking stream abstraction for PHP based on Amp.
https://amphp.org/byte-stream
MIT License
367 stars 30 forks source link

Modify chunk size on the fly #50

Closed ostrolucky closed 5 years ago

ostrolucky commented 5 years ago

I would like to change the chunksize during Resouce(Input|Output)Stream object lifecycle, not just when constructing it. Can we have chunksize mutator, or optional argument in read?

bwoebi commented 5 years ago

There's no technical reason against introducing a setter for it.

However I am curious what is your use case?

ostrolucky commented 5 years ago

This is so program can tweak the chunk size being used based on current r/w speeds

bwoebi commented 5 years ago

I strongly doubt it will bring any benefit, but I'm open to seeing actual benchmarks and be told otherwise (i.e. add your own setter for testing and bench it then).

ostrolucky commented 5 years ago

In that case having it in constructor would also be questionable, wouldn't it?

kelunik commented 5 years ago

I'm fine with a setter there, do you want to provide a PR?