1+ import { Scheduler } from './Scheduler.js' ;
2+
13/**
24 * Error thrown when a queued item's promise is rejected because the item was removed
35 * before its callback could run.
@@ -45,13 +47,38 @@ export class PriorityQueueItemRemovedError extends Error {
4547 */
4648export class PriorityQueue {
4749
48- // returns whether tasks are queued or actively running
50+ /**
51+ * returns whether tasks are queued or actively running
52+ * @readonly
53+ * @type {boolean }
54+ */
4955 get running ( ) {
5056
5157 return this . items . length !== 0 || this . currJobs !== 0 ;
5258
5359 }
5460
61+ /**
62+ * Callback used to schedule when to run jobs next, so more work doesn't happen in a
63+ * single frame than there is time for. Defaults to `requestAnimationFrame`. Should be
64+ * overridden in scenarios where `requestAnimationFrame` is not reliable, such as when
65+ * running in WebXR.
66+ * @type {SchedulingCallback }
67+ * @deprecated
68+ */
69+ get schedulingCallback ( ) {
70+
71+ return this . _schedulingCallback ;
72+
73+ }
74+
75+ set schedulingCallback ( cb ) {
76+
77+ console . log ( 'PriorityQueue: Setting "schedulingCallback" has been deprecated. Use Scheduler to switch to an XRSession rAF, instead.' ) ;
78+ this . _schedulingCallback = cb ;
79+
80+ }
81+
5582 constructor ( ) {
5683
5784 /**
@@ -78,16 +105,9 @@ export class PriorityQueue {
78105 */
79106 this . priorityCallback = null ;
80107
81- /**
82- * Callback used to schedule when to run jobs next, so more work doesn't happen in a
83- * single frame than there is time for. Defaults to `requestAnimationFrame`. Should be
84- * overridden in scenarios where `requestAnimationFrame` is not reliable, such as when
85- * running in WebXR.
86- * @type {SchedulingCallback }
87- */
88- this . schedulingCallback = func => {
108+ this . _schedulingCallback = func => {
89109
90- requestAnimationFrame ( func ) ;
110+ Scheduler . requestAnimationFrame ( func ) ;
91111
92112 } ;
93113
@@ -289,7 +309,7 @@ export class PriorityQueue {
289309
290310 if ( ! this . scheduled ) {
291311
292- this . schedulingCallback ( this . _runjobs ) ;
312+ this . _schedulingCallback ( this . _runjobs ) ;
293313
294314 this . scheduled = true ;
295315
0 commit comments