Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Tick function is not working correctly inside fibers #8960

Copy link
Copy link
@Alimadadi

Description

@Alimadadi
Issue body actions

Description

The following code:

<?php

declare(ticks=1);

register_tick_function(function(){
  if(Fiber::getCurrent() !== null) {
    Fiber::suspend();
  }
});


for($i = 3; $i--;)
{
  $fibers[$i] = new fiber(function (){
    echo "1\n";
    echo "2\n";
    echo "3\n";
  });

  $fibers[$i]->start();
}

Resulted in this output:

1
1
2
3
1
2
3

But I expected this output instead:

1
1
1

Explanation:
If we are inside a fiber, after each tick, the tick function should call Fiber::suspend().
But currently this tick function only works inside first Fiber.

PHP Version

PHP 8.1.8

Operating System

macOS

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.