Skip to content

Commit

Permalink
2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
havelessbemore committed May 10, 2024
1 parent e51c085 commit 7392f8b
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 5 deletions.
9 changes: 9 additions & 0 deletions dist/semafy.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,19 @@ var __defProp$1 = Object.defineProperty;
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "" , value);
class SharedLock {
/**
* @param mutex - The shared mutex to associate.
*/
constructor(mutex) {
/**
* The associated mutex.
*/
__publicField$1(this, "_mutex");
this._mutex = mutex;
}
/**
* The associated mutex.
*/
get mutex() {
return this._mutex;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/semafy.cjs.map

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions dist/semafy.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,27 @@ declare class TimedMutex extends Mutex implements TimedLockable {
*/
declare function lockGuard<T>(mutex: BasicLockable, callbackfn: () => T | Promise<T>): Promise<T>;

/**
* A shared mutex wrapper.
*
* Locking a SharedLock locks the associated shared mutex in shared mode.
*
* If the shared mutex implements {@link SharedTimedLockable}, then SharedLock
* will also implement it. Otherwise, attempts to use timed methods
* (`tryLockFor`, `tryLockUntil`) will result in errors.
*/
declare class SharedLock implements TimedLockable {
/**
* The associated mutex.
*/
protected _mutex: SharedLockable;
/**
* @param mutex - The shared mutex to associate.
*/
constructor(mutex: SharedLockable);
/**
* The associated mutex.
*/
get mutex(): SharedLockable;
get ownsLock(): boolean;
lock(): Promise<void>;
Expand Down
9 changes: 9 additions & 0 deletions dist/semafy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,19 @@ var __defProp$1 = Object.defineProperty;
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "" , value);
class SharedLock {
/**
* @param mutex - The shared mutex to associate.
*/
constructor(mutex) {
/**
* The associated mutex.
*/
__publicField$1(this, "_mutex");
this._mutex = mutex;
}
/**
* The associated mutex.
*/
get mutex() {
return this._mutex;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/semafy.mjs.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "semafy",
"version": "2.0.1",
"version": "2.0.2",
"description": "A robust cross-agent synchronization library.",
"license": "MIT",
"author": "Michael Rojas <[email protected]> (https://github.com/havelessbemore)",
Expand Down
18 changes: 18 additions & 0 deletions src/utils/sharedLock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@ import type { SharedLockable } from "../types/sharedLockable";
import type { SharedTimedLockable } from "../types/sharedTimedLockable";
import type { TimedLockable } from "../types/timedLockable";

/**
* A shared mutex wrapper.
*
* Locking a SharedLock locks the associated shared mutex in shared mode.
*
* If the shared mutex implements {@link SharedTimedLockable}, then SharedLock
* will also implement it. Otherwise, attempts to use timed methods
* (`tryLockFor`, `tryLockUntil`) will result in errors.
*/
export class SharedLock implements TimedLockable {
/**
* The associated mutex.
*/
protected _mutex: SharedLockable;

/**
* @param mutex - The shared mutex to associate.
*/
constructor(mutex: SharedLockable) {
this._mutex = mutex;
}

/**
* The associated mutex.
*/
get mutex(): SharedLockable {
return this._mutex;
}
Expand Down

0 comments on commit 7392f8b

Please sign in to comment.