ciorent 0.8.2 → 0.9.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ciorent",
3
- "version": "0.8.2",
3
+ "version": "0.9.1",
4
4
  "description": "A lightweight, low-overhead concurrency library",
5
5
  "repository": {
6
6
  "type": "git",
package/semaphore.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  /**
2
2
  * @module Semaphores
3
3
  */
4
- import type { UnboundedQueue } from "./queue.js";
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 = [...UnboundedQueue<() => void>, remain: number];
11
+ export type Semaphore = [head: QueueNode, tail: QueueNode, remain: number];
9
12
  /**
10
13
  * Create a semaphore that allows n accesses
11
14
  */
package/semaphore.js CHANGED
@@ -1 +1 @@
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]()};
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 try{await r()}finally{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{};