* Creates a guarded version of f that can only be entered when the supplied * condition allows. * @param {function} condition represents a critical section that may only * be entered when allowed by the condition * @param {function} f function to guard * @returns {function} guarded versio
(condition, f)
| 27 | * @returns {function} guarded version of f |
| 28 | */ |
| 29 | function guard(condition, f) { |
| 30 | return function() { |
| 31 | var args = slice.call(arguments); |
| 32 | |
| 33 | return when(condition()).withThis(this).then(function(exit) { |
| 34 | return when(f.apply(this, args))['finally'](exit); |
| 35 | }); |
| 36 | }; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Creates a condition that allows only n simultaneous executions |
no test coverage detected
searching dependent graphs…