ciorent 0.9.1 → 0.11.0
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/latch.d.ts +2 -2
- package/latch.js +1 -1
- package/package.json +2 -1
- package/semaphore.d.ts +1 -7
- package/semaphore.js +1 -1
package/latch.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* Describe a latch
|
3
3
|
*/
|
4
|
-
export type Latch = [p: Promise<void
|
4
|
+
export type Latch = [p: Promise<void> | void, res: () => void, cb: (res: () => void) => void];
|
5
5
|
export declare const init: <T>() => Latch;
|
6
6
|
/**
|
7
7
|
* Reclose the latch
|
@@ -17,4 +17,4 @@ export declare const open: (c: Latch) => void;
|
|
17
17
|
* Wait for the latch to open
|
18
18
|
* @param c
|
19
19
|
*/
|
20
|
-
export declare const wait: (c: Latch) => Promise<void
|
20
|
+
export declare const wait: (c: Latch) => Promise<void> | void;
|
package/latch.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export let init=()=>{let e=[,,r=>{e[1]=r}];close(e);return e};export let close=e=>{e[0]=new Promise(e[2])};export let open=e=>{e[1]()};export let wait=e=>e[0];
|
1
|
+
export let init=()=>{let e=[,,r=>{e[1]=r}];close(e);return e};export let close=e=>{if(e[0]==null)e[0]=new Promise(e[2])};export let open=e=>{e[1]();e[0]=void 0};export let wait=e=>e[0];
|
package/package.json
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"name": "ciorent",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.11.0",
|
4
4
|
"description": "A lightweight, low-overhead concurrency library",
|
5
|
+
"homepage": "https://re-utils.pages.dev/concurrency",
|
5
6
|
"repository": {
|
6
7
|
"type": "git",
|
7
8
|
"url": "git+https://github.com/re-utils/ciorent.git"
|
package/semaphore.d.ts
CHANGED
@@ -8,18 +8,12 @@ export type QueueNode = [next: QueueNode | undefined, value: () => void];
|
|
8
8
|
/**
|
9
9
|
* Describe a semaphore
|
10
10
|
*/
|
11
|
-
export type Semaphore = [head: QueueNode, tail: QueueNode, remain: number];
|
11
|
+
export type Semaphore = [head: QueueNode, tail: QueueNode, remain: number, register: (cb: () => void) => void];
|
12
12
|
/**
|
13
13
|
* Create a semaphore that allows n accesses
|
14
14
|
*/
|
15
15
|
export declare const init: (n: number) => Semaphore;
|
16
16
|
/**
|
17
|
-
* Queue a task
|
18
|
-
* @param s
|
19
|
-
* @param cb
|
20
|
-
*/
|
21
|
-
export declare const queue: (s: Semaphore, cb: () => Promise<any>) => Promise<void>;
|
22
|
-
/**
|
23
17
|
* Wait until the semaphore allows access
|
24
18
|
*/
|
25
19
|
export declare const acquire: (s: Semaphore) => Promise<void> | void;
|
package/semaphore.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export let init=e=>{let
|
1
|
+
export let init=e=>{let t=[,];let n=[t,t,e,e=>{n[0]=n[0][0]=[,e]}];return n};export let acquire=e=>{if(--e[2]<0)return new Promise(e[3])};export let release=e=>{if(e[2]++<0)(e[1]=e[1][0])[1]()};
|