add zfd for EvIo

Declined
#6 · Created  · Last updated

Declined pull request

Thank you, but I have to decline this PR. Storing zvals is not that easy. One needs to increment the reference counter when the variable goes into a deeper scope (such as a function call, for instance), and decrement it when the object storing the zval is being destroyed, the zval is overwritten by another zval, or zval leaves the current scope, for example. There many cases when we need to take care of the reference counter in order to prevent memory leaks, segmentation faults, and other kinds of memory management issues. So there should be a good reason to go into all those complications. In your particular example the `$socket` variable could be easily fetched from higher-level scope via the `use` language construct, or the `global` statement, for instance. In an OOP-style program the variable could be stored in a class member, and fetched naturally via `$this`. So I can not imagine a situation when storing `$socket` within the watcher would be absolutely necessary. As for the `EvIo` constructor, it only takes the file descriptor from the socket in order to notify the user when the configured event occurs on it. It does not care even if one wraps the file descriptor in some other kind of PHP resource, or an object. (And this is actually possible.) It is the user's responsibility to pass his variables around. Only the user can decide if he needs the socket variable within the callback. Besides, an extra zval would require extra memory even if the user does not use it. So I have to reject your pull request, sorry. By the way, properties are declared in the `php7/pe.c` file.

Closed by: ·2017-12-10

Description

 

0 attachments

0 comments

Loading commits...