Open MaxxAstral opened 10 years ago
Thanks for the encouragement. I continue to work on phpdaemon as time allows. And I certainly stand behind it and respond to bug reports.
In this case, the interface does specify a setup() method. Is that what you had in mind? It's called in the Core_Mediator::setup method, on line 571 https://github.com/shaneharter/PHP-Daemon/blob/master/Core/Worker/Mediator.php#L571 .
If there's an issue and that setup method isn't being called, please let me know and we'll file a more specific bug report.
On Sunday, December 22, 2013, MaxxAstral wrote:
Hi i was wondering if it was possible to allow creating constructors for worker classes that implements Core_IWorker. Much like creating constructors for classes that implements \Core_ITask. It would be quite beneficial to have this feature.
Btw, i love the work you've done on PHP-Daemon. I always dreamt of an efficient creation and management of processes in PHP, and PHP-Daemon made that dream come true. Its a fantastic package overall. Many thanks for the hard work that you've done. Keep it alive and rocking !!
— Reply to this email directly or view it on GitHubhttps://github.com/shaneharter/PHP-Daemon/issues/34 .
Yes thats already there and immensely useful. But to pass some parameters from the main daemon class to the worker objects we need a constructor or something similar. For example like here in the Example file called ParallelTask.php
if (mt_rand(1, 40) == 1) { $sleepfor = mt_rand(60, 180); $this->task(new BigTask($sleepfor, "I just woke up from my {$sleepfor} second sleep")); }
And the relevant constructor in BigTask.php
public function __construct($sleep_duration, $wakeup_message = '') { $this->sleep_duration = $sleep_duration; $this->wakeup_message = $wakeup_message; }
So is this possible with the worker API, or should i stick with the Task API if i want to pass constructor parameter.
I only have an iPad here so forgive me for not just trying myself, but if you made a Core_IWorker object with a similar constructor, does that not work the same as it does with a task object?
There are limits to what you can do with a constructor like that of course because it's run in-process before the fork.
On Sunday, December 22, 2013, MaxxAstral wrote:
Yes thats already there and immensely useful. But to pass some parameters from the main daemon class to the worker objects we need a constructor or something similar. For example like here in the Example file called ParallelTask.php
if (mt_rand(1, 40) == 1) { $sleepfor = mt_rand(60, 180); $this->task(new BigTask($sleepfor, "I just woke up from my {$sleepfor} second sleep")); }
And the relevant constructor in BigTask.php
public function __construct($sleep_duration, $wakeup_message = '') { $this->sleep_duration = $sleep_duration; $this->wakeup_message = $wakeup_message; }
So is this possible with the worker API, or should i stick with the Task API if i want to pass constructor parameter.
— Reply to this email directly or view it on GitHubhttps://github.com/shaneharter/PHP-Daemon/issues/34#issuecomment-31101751 .
No problem. Yes i tried that but i get an error when i try and declare constructors of Core_IWorker classes.
On Tue, Dec 24, 2013 at 12:09 PM, Shane Harter notifications@github.comwrote:
I only have an iPad here so forgive me for not just trying myself, but if you made a Core_IWorker object with a similar constructor, does that not work the same as it does with a task object?
There are limits to what you can do with a constructor like that of course because it's run in-process before the fork.
On Sunday, December 22, 2013, MaxxAstral wrote:
Yes thats already there and immensely useful. But to pass some parameters from the main daemon class to the worker objects we need a constructor or something similar. For example like here in the Example file called ParallelTask.php
if (mt_rand(1, 40) == 1) { $sleepfor = mt_rand(60, 180); $this->task(new BigTask($sleepfor, "I just woke up from my {$sleepfor} second sleep")); }
And the relevant constructor in BigTask.php
public function __construct($sleep_duration, $wakeup_message = '') { $this->sleep_duration = $sleep_duration; $this->wakeup_message = $wakeup_message; }
So is this possible with the worker API, or should i stick with the Task API if i want to pass constructor parameter.
— Reply to this email directly or view it on GitHub< https://github.com/shaneharter/PHP-Daemon/issues/34#issuecomment-31101751>
.
— Reply to this email directly or view it on GitHubhttps://github.com/shaneharter/PHP-Daemon/issues/34#issuecomment-31160765 .
sent via 100% recycled electrons from my mobile command center.
Hi i was wondering if it was possible to allow creating constructors for worker classes that implements Core_IWorker. Much like creating constructors for classes that implements \Core_ITask. It would be quite beneficial to have this feature.
Btw, i love the work you've done on PHP-Daemon. I always dreamt of an efficient creation and management of processes in PHP, and PHP-Daemon made that dream come true. Its a fantastic package overall. Many thanks for the hard work that you've done. Keep it alive and rocking !!