/** * Myext lock (aka binary semaphore aka mutex) * * Copyright (C) 2021 Wojtek Kosior * Redistribution terms are gathered in the `copyright' file. */ /* * Javascript runs single-threaded, with an event loop. Because of that, * explicit synchronization is often not needed. An exception is when we use * an API function that must wait. Ajax is an example. Callback passed to ajax * call doesn't get called immediately, but after some time. In the meantime * some other piece of code might get to execute and modify some variables. * Access to WebExtension local storage is another situation where this problem * can occur. * * This is a solution. A lock object, that can be used to delay execution of * some code until other code finishes its critical work. Locking is wrapped * in a promise. */ "use strict"; (() => { function make_lock() { return {free: true, queue: []}; } function _lock(lock, cb) { if (lock.free) { lock.free = false; setTimeout(cb); } else { lock.queue.push(cb); } } function lock(lock) { return new Promise((resolve, reject) => _lock(lock, resolve)); } function unlock(lock) { if (lock.free) throw new Exception("Attempting to release a free lock"); if (lock.queue.length === 0) { lock.free = true; } else { let cb = lock.queue[0]; lock.queue.splice(0, 1); setTimeout(cb); } } window.make_lock = make_lock; window.lock = lock; window.unlock = unlock; })(); 2068c94ba828a04559007d4b957be83b'>diff
path: root/gnu/packages/man.scm
AgeCommit message (Expand)Author
2018-12-20gnu: Add scdoc....Rutger Helling
2018-11-19gnu: help2man: Add 1.47.8....Ludovic Courtès
2018-05-08Merge branch 'master' into core-updatesMark H Weaver
2018-05-06Revert "gnu: man-db: Embed absolute reference to 'preconv'."...Marius Bakke
2018-05-06Merge branch 'master' into core-updatesMarius Bakke
2018-05-06gnu: man-db: Embed absolute reference to 'preconv'....Marius Bakke
2018-05-02gnu: man-pages: Update to 4.16....Tobias Geerinckx-Rice
2018-04-21Merge branch 'master' into core-updatesMark H Weaver
2018-04-17gnu: man-db: Update to 2.8.3....Tobias Geerinckx-Rice
2018-03-23gnu: man-db: Return #t from all phases....Mark H Weaver
2018-03-14Merge branch 'master' into core-updatesRicardo Wurmus
2018-03-14gnu: man-db: Update to 2.8.2....Marius Bakke