ciorent 0.9.1 → 0.10.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/package.json +2 -1
- package/semaphore.d.ts +1 -7
- package/semaphore.js +1 -1
package/package.json
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"name": "ciorent",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.10.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]()};
|