Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
b8429738
Commit
b8429738
authored
Feb 21, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mutex does not do what is expected?
parent
45f127cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
test/mutex_test.js
test/mutex_test.js
+47
-0
No files found.
test/mutex_test.js
View file @
b8429738
...
...
@@ -287,6 +287,53 @@
});
});
test
(
'
lockAndRun cancel stop second execution
'
,
function
()
{
var
mutex
=
new
Mutex
(),
counter
=
0
;
stop
();
expect
(
2
);
function
assertCounter
(
value
)
{
equal
(
counter
,
value
);
counter
+=
1
;
}
function
callback1
()
{
assertCounter
(
0
);
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
delay
(
50
);
})
.
push
(
function
()
{
assertCounter
(
1
);
});
}
function
callback2
()
{
assertCounter
(
2
);
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
delay
(
50
);
})
.
push
(
function
()
{
assertCounter
(
-
999
);
ok
(
false
,
'
Should not reach that code
'
);
});
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
mutex
.
lockAndRun
(
callback1
);
})
.
push
(
function
()
{
var
promise
=
mutex
.
lockAndRun
(
callback2
);
promise
.
cancel
(
'
cancel callback2
'
);
return
RSVP
.
delay
(
200
);
})
.
push
(
function
()
{
assertCounter
(
3
);
})
.
always
(
function
()
{
start
();
});
});
test
(
'
lockAndRun cancel does not cancel previous execution
'
,
function
()
{
var
mutex
=
new
Mutex
(),
counter
=
0
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment