Skip to content

Async jobs fibers - #1

Open
xtrime-ru wants to merge 17 commits into
eddmann:mainfrom
xtrime-ru:async-jobs-fibers
Open

xtrime-ru wants to merge 17 commits into
eddmann:mainfrom
xtrime-ru:async-jobs-fibers

Conversation

@xtrime-ru

@xtrime-ru xtrime-ru commented Sep 12, 2026 •

Copy link
Copy Markdown

Summary

  • Add Promise job APIs (hasPendingJobs() and executePendingJobs()) and support awaiting Promises through PHP Fibers, Revolt, and Amphp v3.
  • Allow concurrent JS callback Promises to settle independently, with fair job processing that yields to the event loop.
  • Add quickjs.postMessage(value) and QuickJS::drainMessages() for data-only messages with snapshot semantics and a configurable queue limit.
  • Replace MessagePack in JS↔PHP calls with direct native value conversion.

Validation

  • 6 Rust unit tests and the full PHP test suite passed in Docker with PHP 8.5 NTS.
  • Covered Fiber suspension, concurrent callbacks, job fairness, message limits, large payloads, and error recovery.

Track active contexts per engine, refresh the QuickJS stack boundary, block
unsafe Fiber switches, apply callback timeouts, and bound nested values.
Flush dropped callback references at each outer entry and test recovery.
Expose hasPendingJobs and runJobs for host event loops. Enforce per-batch
job and wall-time budgets, reject isolated or reentrant pumping, and cover
Promise resolution, callback cleanup, timeouts, and Fiber resumption.
Convert callback arguments and queued guest messages natively. Bound queue
size, reject non-data payloads, discard partial messages on failure, and
return job progress to the host for asynchronous scheduling.
Build and test with PHP 8.5 and Rust 1.96.1 using a bind-mounted checkout. Keep Cargo and Composer caches in .cache and install integration-test dependencies in CI.
Automatically await eval and saved callback results using QuickJS Promise state. Preserve Fiber ownership, queue foreign callback calls with their results and errors, and wake external waits at the execution deadline. Share native callback conversion and cover Revolt/Amp flows with regression tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant