Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhpClient should be wrapped in workers #48

Open
kevinresol opened this issue Oct 8, 2016 · 6 comments
Open

PhpClient should be wrapped in workers #48

kevinresol opened this issue Oct 8, 2016 · 6 comments

Comments

@kevinresol
Copy link
Member

I just realized that I have forgotten that bit.

@kevinresol
Copy link
Member Author

I am not sure if this really works. Because php doesn't support threads at all. (even pthread is not really what we needed, because it doesn't share references)

@back2dos
Copy link
Member

back2dos commented Dec 6, 2016

Threads are not a requirement though. The runloop could still make progress two downloads in parallel, so long as each of them is performed bit by bit.

@kevinresol
Copy link
Member Author

Did I miss something? I thought the http request a sync operation. How does that parallelize?

@back2dos
Copy link
Member

back2dos commented Dec 6, 2016

Well, in theory the pipes drive the sources which each read a (possibly empty) slice through a worker which hands control back to the runloop, which then schedules the next worker to progress. The IO occurs in parallel anyway (since the kernel with its TCP stack and also the server on the other end progress independently). The trick is not to block until all data is read, but just read it bit by bit. And ideally not to block if no data exists, but just yield Progress.NONE so that other operations may check their status.

@kevinresol
Copy link
Member Author

kevinresol commented Dec 6, 2016

Oh that means need to find out the "bit by bit" api in php. But I have no idea atm.

Or maybe just replace readAll with something else here: https://github.com/haxetink/tink_http/blob/21ac733/src/tink/http/Client.hx#L160

@benmerckx
Copy link
Member

benmerckx commented Dec 6, 2016

I created a non-blocking tink_tcp connection for php based on stream_select which might make it easier to accomplish this if read bit by bit. But it also created a mess in the source hence my comment haxetink/tink_tcp#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants