Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
139
Merge Requests
139
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
486c7327
Commit
486c7327
authored
Dec 28, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_core: remove unused code
renderJS's mutex must be used instead
parent
3ae314f3
Pipeline
#12984
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
111 deletions
+0
-111
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_global.js.js
...inTemplateItem/portal_skins/erp5_core/gadget_global.js.js
+0
-111
No files found.
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_global.js.js
View file @
486c7327
...
...
@@ -182,115 +182,4 @@
});
};
/** Internal function to prepare gadget to hold a mutex */
function
ensureLockable
(
gadget
)
{
if
(
gadget
.
props
===
undefined
)
{
gadget
.
props
=
{};
}
// waiting_line is container of mutexes which already blocks some Promise
if
(
gadget
.
props
.
waiting_line
===
undefined
)
{
gadget
.
props
.
waiting_line
=
[];
}
}
/** Synchronously lock gadget and return previous lock's promise.
NON-RECURSIVE lock! If you lock inside locked execution you will wait forever.
If used in a Queue (@see lockGadgetInQueue) it blocks when acquiring the lock.
*/
window
.
lockGadget
=
function
(
gadget
)
{
var
ahead_of_me
;
ensureLockable
(
gadget
);
// step in line
gadget
.
props
.
waiting_line
.
push
(
RSVP
.
defer
());
if
(
gadget
.
props
.
waiting_line
.
length
>=
2
)
{
// wait for the promise ahead of me
ahead_of_me
=
gadget
.
props
.
waiting_line
[
gadget
.
props
.
waiting_line
.
length
-
2
].
promise
;
}
else
{
ahead_of_me
=
RSVP
.
resolve
();
}
// return previous lock's Promise to postpone execution
return
ahead_of_me
;
};
/** Lock gadget as a step in RSVP.Queue waiting for previous lock to unlock.
Use in RSVP.Queue to block execution until manually called `unlockGadget`.
Both lock/unlockGadget pass through any value in RSVP.Queue manner.
Pass through any value.
Example:
new RSVP.Queue()
.push(function () {return some_value;})
.push(lockGadgetInQueue(gadget), lockGadgetInFailedQueue(gadget))
.push(function (some_value) {return someWork(some_value);})
.push(unlockGadgetInQueue(gadget), unlockGadgetInFailedQueue(gadget));
*/
window
.
lockGadgetInQueue
=
function
(
gadget
)
{
// return function to be used in RSVP.Queue
return
function
(
pass_through
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
window
.
lockGadget
(
gadget
);
})
.
push
(
function
()
{
return
pass_through
;
});
};
};
/** Lock Gagdet in Queue but intended to be used in "fail" branch (the second function).
Rethrows any argument.
*/
window
.
lockGadgetInFailedQueue
=
function
(
gadget
)
{
// return function to be used in RSVP.Queue
return
function
(
error
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
window
.
lockGadget
(
gadget
);
})
.
push
(
function
()
{
throw
error
;
});
};
};
/** Synchronously unlock gadget by resolving props.mutex.promise.
That promise is most likely blocking some RSVP.Queue or is then-ed on another
Promise.
*/
window
.
unlockGadget
=
function
(
gadget
)
{
if
(
gadget
.
props
===
undefined
||
gadget
.
props
.
waiting_line
===
undefined
||
gadget
.
props
.
waiting_line
.
length
===
0
)
{
throw
new
Error
(
"
Gadget
"
+
gadget
+
"
is not locked!
"
);
}
gadget
.
props
.
waiting_line
.
shift
().
resolve
();
};
/** Unlock gadget without blocking as a step in RSVP.Queue.
Pass through any value. Not re-throwing errors in fail branch!
For example @see lockGadgetInQueue.
*/
window
.
unlockGadgetInQueue
=
function
(
gadget
)
{
return
function
(
pass_through
)
{
window
.
unlockGadget
(
gadget
);
return
pass_through
;
};
};
/** Unlock gadget without blocking and throw any argument received. */
window
.
unlockGadgetInFailedQueue
=
function
(
gadget
)
{
return
function
(
error
)
{
window
.
unlockGadget
(
gadget
);
throw
error
;
};
};
}(
window
,
RSVP
,
FileReader
));
\ No newline at end of file
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