ciorent 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/semaphore.d.ts +3 -3
- package/semaphore.js +1 -1
package/package.json
CHANGED
package/semaphore.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
/**
|
2
2
|
* @module Semaphores
|
3
3
|
*/
|
4
|
-
import type {
|
4
|
+
import type { UnboundedQueue } from "./queue.js";
|
5
5
|
/**
|
6
6
|
* Describe a semaphore
|
7
7
|
*/
|
8
|
-
export type Semaphore = [...UnboundedQueue<() => void>,
|
8
|
+
export type Semaphore = [...UnboundedQueue<() => void>, remain: number];
|
9
9
|
/**
|
10
10
|
* Create a semaphore that allows n accesses
|
11
11
|
*/
|
@@ -19,7 +19,7 @@ export declare const queue: (s: Semaphore, cb: () => Promise<any>) => Promise<vo
|
|
19
19
|
/**
|
20
20
|
* Wait until the semaphore allows access
|
21
21
|
*/
|
22
|
-
export declare const acquire: (s: Semaphore) => Promise<void
|
22
|
+
export declare const acquire: (s: Semaphore) => Promise<void> | void;
|
23
23
|
/**
|
24
24
|
* Signal to the semaphore to release access
|
25
25
|
*/
|
package/semaphore.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export let init=e=>{let
|
1
|
+
export let init=e=>{let r=[,];return[r,r,e]};export let queue=async(e,r)=>{if(--e[2]<0){e[0]=e[0][0]=[,r]}else{await r();release(e)}};export let acquire=e=>{if(--e[2]<0)return new Promise(r=>{e[0]=e[0][0]=[,r]})};export let release=e=>{if(e[2]++<0)(e[1]=e[1][0])[1]()};
|