Title: [EventLoop] Implement enter idle · Issue #254 · reactphp/reactphp · GitHub
Open Graph Title: [EventLoop] Implement enter idle · Issue #254 · reactphp/reactphp
X Title: [EventLoop] Implement enter idle · Issue #254 · reactphp/reactphp
Description: Hello, I'm trying to execute some code in an interval kind of way, but I don't want to interfere with other events that could be trigger in each tick. So, I'm looking into a "enter idle" state. I imagine that in each tick that we will wa...
Open Graph Description: Hello, I'm trying to execute some code in an interval kind of way, but I don't want to interfere with other events that could be trigger in each tick. So, I'm looking into a "enter idle" state. I i...
X Description: Hello, I'm trying to execute some code in an interval kind of way, but I don't want to interfere with other events that could be trigger in each tick. So, I'm looking into a "enter...
Opengraph URL: https://github.com/reactphp/reactphp/issues/254
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[EventLoop] Implement enter idle","articleBody":"Hello,\n\nI'm trying to execute some code in an interval kind of way, but I don't want to interfere with other events that could be trigger in each tick. So, I'm looking into a \"enter idle\" state.\n\nI imagine that in each tick that we will wait forever to the stream, instead we enter idle and we will wait for stream in the next tick. It should also be an exception that the first tick will not enter idle, but is not that important.\n\nI imagine the following:\n\n``` php\n$loop->addTimer(0.01, function ($timer) use ($loop) {\n echo 'exit' . PHP_EOL;\n $loop->end();\n});\n$loop->addTimer(0.005, function ($timer) {\n echo 'hello' . PHP_EOL;\n});\n$loop->addEnterIdle(function ($loop) {\n echo 'waiting' . PHP_EOL;\n});\n\n$this->expectOutputString(\n 'waiting' . PHP_EOL . 'hello' . PHP_EOL .\n 'waiting' . PHP_EOL . 'exit' . PHP_EOL\n);\n\n$loop->run();\n```\n\nThe logic I found is:\n\n```\nTick with no timers scheduled and $read || $write == false: if not flag, enter idle and set flag.\nTick with events, unset flag.\n```\n\nFor some time now I'm trying to understand how this should work, but it goes beyond my knowledge.\n\nI asked this a few days ago in the IRC channel, and I was pointed to `futureTick()` of #249. But the differences I need are:\n1. My code need to be executed every possible time without needed to re add the same callback.\n2. My code don't need to be executed when something else (stream read/write; timer) are executing.\n3. My code need to be executed only after something happened (to minimize the processing).\n\nAny help figuring out this will be much appreciated. Thank you.\n","author":{"url":"https://github.com/jm42","@type":"Person","name":"jm42"},"datePublished":"2013-12-27T15:19:51Z","url":"https://github.com/reactphp/reactphp/issues/254"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ce88100b-1f9c-7d65-f4db-571d5780cc59 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 840A:31D8FB:5D2D7B:808807:6B009536 |
| html-safe-nonce | c4fa5b565073911393ff666e485193c833fcf854e6ff1e8551abc4247f28769e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDBBOjMxRDhGQjo1RDJEN0I6ODA4ODA3OjZCMDA5NTM2IiwidmlzaXRvcl9pZCI6IjE0Mzg4MjE0MTYxMTkwODAyNDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | aebb73cbe0b35704e535dc27df3fee61e61248007d0c50c72dd0a5169f8743e3 |
| hovercard-subject-tag | issue:24823324 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/reactphp/reactphp/254/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7d4d600a140230bc0f144f4449fd47941e4b129de7d994381803f128a43e1dc1/reactphp/reactphp/issues/254 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7d4d600a140230bc0f144f4449fd47941e4b129de7d994381803f128a43e1dc1/reactphp/reactphp/issues/254 |
| og:image:alt | Hello, I'm trying to execute some code in an interval kind of way, but I don't want to interfere with other events that could be trigger in each tick. So, I'm looking into a "enter idle" state. I i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jm42 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 552480023d6963d7f188d82f8cd5f3fe5046244607d769b794462821d9ea1b29 |
| turbo-cache-control | no-preview |
| go-import | github.com/reactphp/reactphp git https://github.com/reactphp/reactphp.git |
| octolytics-dimension-user_id | 1696866 |
| octolytics-dimension-user_login | reactphp |
| octolytics-dimension-repository_id | 4287921 |
| octolytics-dimension-repository_nwo | reactphp/reactphp |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 4287921 |
| octolytics-dimension-repository_network_root_nwo | reactphp/reactphp |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | caf54e38b10face642f6cc1c79e4562e7ee52e3c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width