Skip to content

Commit

Permalink
Revert queue
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 committed Mar 2, 2021
1 parent 39bc7eb commit 34e4aad
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 16 deletions.
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/edit-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"@wordpress/notices": "file:../notices",
"@wordpress/plugins": "file:../plugins",
"@wordpress/primitives": "file:../primitives",
"@wordpress/priority-queue": "file:../priority-queue",
"@wordpress/url": "file:../url",
"classnames": "^2.2.5",
"downloadjs": "^1.4.7",
Expand Down
4 changes: 0 additions & 4 deletions packages/priority-queue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ queue.add( ctx2, () => console.log( 'This won\'t be printed' ) );
queue.add( ctx2, () => console.log( 'This will be printed second' ) );
```

_Parameters_

- _callbacksToProcessPerRun_ `[number]`:

_Returns_

- `WPPriorityQueue`: Queue object with `add`, `flush` and `reset` methods.
Expand Down
13 changes: 3 additions & 10 deletions packages/priority-queue/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ import requestIdleCallback from './request-idle-callback';
* queue.add( ctx2, () => console.log( 'This will be printed second' ) );
*```
*
* @param {number} [callbacksToProcessPerRun]
* @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.
*/
export const createQueue = ( callbacksToProcessPerRun ) => {
export const createQueue = () => {
/** @type {WPPriorityQueueContext[]} */
let waitingList = [];

Expand All @@ -76,13 +75,12 @@ export const createQueue = ( callbacksToProcessPerRun ) => {
let isRunning = false;

/**
* Callback to process as much queue as time and `callbacksToProcessPerRun` permits.
* Callback to process as much queue as time permits.
*
* @param {IdleDeadline|number} deadline Idle callback deadline object, or
* animation frame timestamp.
*/
const runWaitingList = ( deadline ) => {
let tasksProcessed = 0;
const hasTimeRemaining =
typeof deadline === 'number'
? () => false
Expand All @@ -103,12 +101,7 @@ export const createQueue = ( callbacksToProcessPerRun ) => {
// loops and race conditions in the queue.
callback();
elementsMap.delete( nextElement );
tasksProcessed++;
} while (
hasTimeRemaining() &&
( ! callbacksToProcessPerRun ||
tasksProcessed < callbacksToProcessPerRun )
);
} while ( hasTimeRemaining() );

requestIdleCallback( runWaitingList );
};
Expand Down

0 comments on commit 34e4aad

Please sign in to comment.