ciorent 0.8.1 → 0.9.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 +1 -1
- package/semaphore.d.ts +6 -3
- package/semaphore.js +1 -1
- package/queue.d.ts +0 -16
- package/queue.js +0 -1
package/package.json
CHANGED
package/semaphore.d.ts
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
/**
|
2
2
|
* @module Semaphores
|
3
3
|
*/
|
4
|
-
|
4
|
+
/**
|
5
|
+
* Describe a singly linked list node
|
6
|
+
*/
|
7
|
+
export type QueueNode = [next: QueueNode | undefined, value: () => void];
|
5
8
|
/**
|
6
9
|
* Describe a semaphore
|
7
10
|
*/
|
8
|
-
export type Semaphore = [
|
11
|
+
export type Semaphore = [head: QueueNode, tail: QueueNode, remain: number];
|
9
12
|
/**
|
10
13
|
* Create a semaphore that allows n accesses
|
11
14
|
*/
|
@@ -19,7 +22,7 @@ export declare const queue: (s: Semaphore, cb: () => Promise<any>) => Promise<vo
|
|
19
22
|
/**
|
20
23
|
* Wait until the semaphore allows access
|
21
24
|
*/
|
22
|
-
export declare const acquire: (s: Semaphore) => Promise<void
|
25
|
+
export declare const acquire: (s: Semaphore) => Promise<void> | void;
|
23
26
|
/**
|
24
27
|
* Signal to the semaphore to release access
|
25
28
|
*/
|
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]()};
|
package/queue.d.ts
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @module Queue types
|
3
|
-
* @private
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* Describe a queue node (singly linked list node)
|
7
|
-
*/
|
8
|
-
export type QueueNode<T> = [next: QueueNode<T> | undefined, value: T];
|
9
|
-
/**
|
10
|
-
* Describe an unbounded queue
|
11
|
-
*/
|
12
|
-
export type UnboundedQueue<T> = [head: QueueNode<T>, tail: QueueNode<T>];
|
13
|
-
/**
|
14
|
-
* Cached promise callback
|
15
|
-
*/
|
16
|
-
export type PromiseFn<T = any> = (res: (value?: T) => void) => void;
|
package/queue.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export{};
|