Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make possible to add priority for given task #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Make possible to add priority for given task #13

wants to merge 1 commit into from

Conversation

MateuszLeo
Copy link

@MateuszLeo MateuszLeo commented Apr 16, 2021

This patch adds possibility to add priority for given task.
It will allow schedule resolving semaphore in order which will be dictated by priority of tasks. Priority with lower number will be executed first.

const s = new Semaphore(1);
function task(priority) {
    const release = await s.acquire(priority);
    release();
}
await Promise.all([task(3), task(1), task(2), task(1)]); //Will execute task in [1, 1, 2, 3] order. 

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