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

Locking timeout #24

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

anton-iskryzhytskyi
Copy link

Relates to #16

web-locks.js Outdated Show resolved Hide resolved
web-locks.js Outdated Show resolved Hide resolved
@tshemsedinov
Copy link
Member

This PR should not contain commits not related to timeout.

@anton-iskryzhytskyi
Copy link
Author

Updated, ready for review, @tshemsedinov

Copy link
Member

@tshemsedinov tshemsedinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need to use clearTimeout on abort?

test/lock-time.js Outdated Show resolved Hide resolved
test/steps.js Outdated Show resolved Hide resolved
test/thread-worker.js Outdated Show resolved Hide resolved
web-locks.js Outdated Show resolved Hide resolved
web-locks.js Outdated Show resolved Hide resolved
web-locks.js Outdated
this.buffer = buffer ? buffer : new SharedArrayBuffer(4);
this.flag = new Int32Array(this.buffer, 0, 1);
if (!buffer) Atomics.store(this.flag, 0, UNLOCKED);
}

enter(handler) {
enter(handler, timeout) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That it much better, but we need to compare passing timeout and timer instance.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need to use clearTimeout on abort?

Hmm, maybe it would be better to throw an error on timeout, similar to abort behavior?
Also, move all resolve / reject invocations to one place.

specify imported file extensions
@tshemsedinov
Copy link
Member

You are doing good code but mixing multiple changes into one PR, we need to talk about process.

Comment on lines +57 to +58
if (timeout)
timer = setTimeout(finalize, timeout, new TimeoutError('Time Out'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (timeout)
timer = setTimeout(finalize, timeout, new TimeoutError('Time Out'));
if (timeout) {
timer = setTimeout(finalize, timeout, new TimeoutError('Time Out'));
}

anton-iskryzhytskyi added a commit to anton-iskryzhytskyi/web-locks that referenced this pull request Mar 19, 2020
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.

2 participants