mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: initial proposal for multithreaded execution
This commit is contained in:
committed by
Joachim Van Herwegen
parent
32245fc604
commit
236bbc6e5d
@@ -1,6 +1,6 @@
|
||||
import cluster from 'cluster';
|
||||
import AsyncLock from 'async-lock';
|
||||
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';
|
||||
import type { SingleThreaded } from '../../init/cluster/SingleThreaded';
|
||||
import { getLoggerFor } from '../../logging/LogUtil';
|
||||
import { InternalServerError } from '../errors/InternalServerError';
|
||||
import type { ResourceLocker } from './ResourceLocker';
|
||||
@@ -11,7 +11,7 @@ import type { ResourceLocker } from './ResourceLocker';
|
||||
* in a memory leak if locks are never unlocked, so make sure this is covered with expiring locks for example,
|
||||
* and/or proper `finally` handles.
|
||||
*/
|
||||
export class MemoryResourceLocker implements ResourceLocker {
|
||||
export class MemoryResourceLocker implements ResourceLocker, SingleThreaded {
|
||||
protected readonly logger = getLoggerFor(this);
|
||||
|
||||
private readonly locker: AsyncLock;
|
||||
@@ -20,10 +20,6 @@ export class MemoryResourceLocker implements ResourceLocker {
|
||||
public constructor() {
|
||||
this.locker = new AsyncLock();
|
||||
this.unlockCallbacks = {};
|
||||
if (cluster.isWorker) {
|
||||
this.logger.warn(`MemoryResourceLocker is not thread-safe/process-safe!
|
||||
You should only use this locker in a single-thread/single-process CSS setup.`);
|
||||
}
|
||||
}
|
||||
|
||||
public async acquire(identifier: ResourceIdentifier): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user