0

I try to use code from the examples (Stacking.php):

$worker = new ExampleWorker("My Worker Thread");
$work = array();
while($i++<10){
    printf(
        "Stacking: %d/%d\n", $i, $worker->stack($work[]=new Work(array(rand()*100)))
    );
}

I would like to adopt this example, put this in infinite WHILE loop waiting for events from database and stack new elements when they appear.

There will be huge amount of events to stack, I can't store all of them in $work array and would like to clean it somehow or not use at all.

The problem is that when I change:

$worker->stack($work[]=new Work(array(rand()*100))

to

$worker->stack(new Work(array(rand()*100))

PHP process segfaults after first worker finishes

How can I put $worker->stack in infinite loop without having to store reference to each stacked work?

1 Answer 1

1

The sort answer is; you cannot.

The details of how the implementation works and why are laid out here: https://gist.github.com/krakjoe/6437782

Anything I say will just be a repetition of that, in any case you will benefit from reading the whole document in it's entirety.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.