2626use Boson \Internal \BootHandler \WindowsDetachConsoleBootHandler ;
2727use Boson \Internal \DeferRunner \DeferRunnerInterface ;
2828use Boson \Internal \DeferRunner \NativeShutdownFunctionRunner ;
29+ use Boson \Internal \Poller \SaucerPoller ;
2930use Boson \Internal \QuitHandler \PcntlQuitHandler ;
3031use Boson \Internal \QuitHandler \QuitHandlerInterface ;
3132use Boson \Internal \QuitHandler \WindowsQuitHandler ;
3233use Boson \Internal \Saucer \Saucer ;
3334use Boson \Internal \Saucer \SaucerInterface ;
3435use Boson \Internal \ThreadsCountResolver ;
36+ use Boson \Poller \PollerInterface ;
3537use Boson \Shared \Marker \BlockingOperation ;
3638use Boson \Shared \Marker \RequiresDealloc ;
3739use Boson \WebView \WebView ;
4042use Boson \Window \Window ;
4143use FFI \CData ;
4244use Psr \EventDispatcher \EventDispatcherInterface ;
43- use Revolt \EventLoop ;
4445
4546/**
4647 * @template-implements IdentifiableInterface<ApplicationId>
@@ -165,6 +166,11 @@ class Application implements
165166 */
166167 private readonly EventListener $ listener ;
167168
169+ /**
170+ * An application poller interface.
171+ */
172+ public readonly PollerInterface $ poller ;
173+
168174 /**
169175 * @param EventDispatcherInterface|null $dispatcher an optional event
170176 * dispatcher for handling application events
@@ -208,6 +214,7 @@ public function __construct(
208214 $ this ->api = $ this ->createLibSaucer ($ info ->library , $ this ->os ->family , $ this ->cpu ->arch );
209215 $ this ->id = $ this ->createApplicationId ($ this ->api , $ this ->info ->name , $ this ->info ->threads );
210216 $ this ->windows = $ this ->createWindowManager ($ this ->api , $ this , $ info , $ this ->listener );
217+ $ this ->poller = $ this ->createApplicationPoller ($ this ->api );
211218
212219 // Initialization of Application's API
213220 $ this ->dialog = new ApplicationDialog ($ this ->api , $ this , $ this ->listener );
@@ -222,6 +229,14 @@ public function __construct(
222229 $ this ->boot ();
223230 }
224231
232+ /**
233+ * Create an application event-loop.
234+ */
235+ protected function createApplicationPoller (SaucerInterface $ saucer ): PollerInterface
236+ {
237+ return new SaucerPoller ($ this ->id , $ saucer );
238+ }
239+
225240 /**
226241 * Creates a new instance of {@see SaucerInterface} that provides access to the
227242 * native WebView API library. The returned object allows interacting with
@@ -501,17 +516,9 @@ public function run(): void
501516
502517 $ this ->listener ->dispatch (new ApplicationStarted ($ this ));
503518
504- EventLoop::repeat (0 , function (string $ id ): void {
505- if ($ this ->isRunning === false ) {
506- EventLoop::cancel ($ id );
507-
508- return ;
509- }
510-
511- $ this ->api ->saucer_application_run_once ($ this ->id ->ptr );
512- });
513-
514- EventLoop::run ();
519+ while ($ this ->isRunning ) {
520+ $ this ->poller ->next ();
521+ }
515522 }
516523
517524 /**
0 commit comments