@reactive-js/schedulers
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -6,4 +6,4 @@ "use strict"; | ||
constructor() { | ||
this._inScheduledContinuation = false; | ||
this.currentDisposable = disposable_1.disposed; | ||
this._inScheduledContinuation = false; | ||
this.startTime = 0; | ||
@@ -10,0 +10,0 @@ this.shouldYield = () => this.currentDisposable.isDisposed || |
@@ -15,4 +15,4 @@ "use strict"; | ||
super(); | ||
this._now = 0; | ||
this.disposable = disposable_1.createDisposable(); | ||
this._now = 0; | ||
this.microTaskTicks = 0; | ||
@@ -19,0 +19,0 @@ this.taskIDCount = 0; |
import { createSerialDisposable, disposed, } from "@reactive-js/disposable"; | ||
export class AbstractScheduler { | ||
constructor() { | ||
this._inScheduledContinuation = false; | ||
this.currentDisposable = disposed; | ||
this._inScheduledContinuation = false; | ||
this.startTime = 0; | ||
@@ -7,0 +7,0 @@ this.shouldYield = () => this.currentDisposable.isDisposed || |
@@ -13,4 +13,4 @@ import { createDisposable, throwIfDisposed, } from "@reactive-js/disposable"; | ||
super(); | ||
this._now = 0; | ||
this.disposable = createDisposable(); | ||
this._now = 0; | ||
this.microTaskTicks = 0; | ||
@@ -17,0 +17,0 @@ this.taskIDCount = 0; |
import { DisposableLike } from "@reactive-js/disposable"; | ||
import { SchedulerLike, SchedulerContinuationLike } from "@reactive-js/scheduler"; | ||
export declare abstract class AbstractScheduler implements SchedulerLike { | ||
private _inScheduledContinuation; | ||
private currentDisposable; | ||
private _inScheduledContinuation; | ||
private startTime; | ||
@@ -7,0 +7,0 @@ private shouldYield; |
{ | ||
"name": "@reactive-js/schedulers", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "dist/cjs/index.js", | ||
@@ -20,4 +20,4 @@ "module": "dist/esm5/index.js", | ||
"dependencies": { | ||
"@reactive-js/disposable": "^0.0.2", | ||
"@reactive-js/scheduler": "^0.0.2", | ||
"@reactive-js/disposable": "^0.0.3", | ||
"@reactive-js/scheduler": "^0.0.3", | ||
"tslib": "^1.10.0" | ||
@@ -50,3 +50,3 @@ }, | ||
}, | ||
"gitHead": "900b8250606308140b72784e35b22301fcc10010" | ||
"gitHead": "c8b86e65e44ab3857d6242aaa29ea7716d842240" | ||
} |
@@ -14,6 +14,5 @@ import { | ||
export abstract class AbstractScheduler implements SchedulerLike { | ||
private _inScheduledContinuation = false; | ||
private currentDisposable: DisposableLike = disposed; | ||
private _inScheduledContinuation = false; | ||
private startTime = 0; | ||
private shouldYield = () => | ||
@@ -20,0 +19,0 @@ this.currentDisposable.isDisposed || |
@@ -14,11 +14,6 @@ import { | ||
class PerfTestingSchedulerImpl implements VirtualTimeSchedulerResourceLike { | ||
get isDisposed() { | ||
return this.disposable.isDisposed; | ||
} | ||
readonly inScheduledContinuation = true; | ||
readonly now = 0; | ||
private readonly disposable: DisposableLike = createDisposable(); | ||
private readonly queue: SchedulerContinuationLike[] = []; | ||
constructor() { | ||
@@ -30,2 +25,6 @@ this.disposable.add(() => { | ||
get isDisposed() { | ||
return this.disposable.isDisposed; | ||
} | ||
add( | ||
@@ -32,0 +31,0 @@ disposable: DisposableOrTeardown, |
@@ -13,8 +13,4 @@ /** @ignore */ | ||
class PriorityQueueImpl<T> implements PriorityQueueLike<T> { | ||
get count(): number { | ||
return this.values.length; | ||
} | ||
private readonly compare: (a: T, b: T) => number; | ||
private readonly values: Array<T> = []; | ||
constructor(compare: (a: T, b: T) => number) { | ||
@@ -24,2 +20,6 @@ this.compare = compare; | ||
get count(): number { | ||
return this.values.length; | ||
} | ||
clear() { | ||
@@ -26,0 +26,0 @@ this.values.length = 0; |
@@ -50,14 +50,2 @@ import { | ||
class PrioritySchedulerResourceImpl implements PrioritySchedulerResourceLike { | ||
get inScheduledContinuation(): boolean { | ||
return this.currentTask !== undefined; | ||
} | ||
get isDisposed(): boolean { | ||
return this.disposable.isDisposed; | ||
} | ||
get now(): number { | ||
return this.hostScheduler.now; | ||
} | ||
private readonly disposable: SerialDisposableLike; | ||
@@ -68,58 +56,5 @@ private readonly hostScheduler: SchedulerLike; | ||
> = createPriorityQueue(comparator); | ||
private taskIDCounter = 0; | ||
constructor(hostScheduler: SchedulerLike) { | ||
this.disposable = createSerialDisposable(); | ||
this.hostScheduler = hostScheduler; | ||
this.disposable.add(() => this.queue.clear()); | ||
} | ||
add( | ||
disposable: DisposableOrTeardown, | ||
...disposables: DisposableOrTeardown[] | ||
) { | ||
this.disposable.add(disposable, ...disposables); | ||
} | ||
dispose() { | ||
this.disposable.dispose(); | ||
} | ||
remove( | ||
disposable: DisposableOrTeardown, | ||
...disposables: DisposableOrTeardown[] | ||
) { | ||
this.disposable.remove(disposable, ...disposables); | ||
} | ||
schedule( | ||
continuation: SchedulerContinuationLike, | ||
priority: number, | ||
delay = 0, | ||
): DisposableLike { | ||
const startTime = this.now; | ||
const dueTime = startTime + delay; | ||
const task = { | ||
taskID: this.taskIDCounter++, | ||
continuation, | ||
disposable: createDisposable(), | ||
priority, | ||
startTime, | ||
dueTime, | ||
}; | ||
this.queue.push(task); | ||
this.scheduleDrainQueue(task); | ||
this.add(task.disposable); | ||
task.disposable.add(() => this.remove(task.disposable)); | ||
return task.disposable; | ||
} | ||
private currentTask: ScheduledTaskLike | undefined = undefined; | ||
private currentShouldYield: (() => boolean) | undefined = undefined; | ||
private shouldYield = () => { | ||
@@ -145,3 +80,2 @@ const currentTaskIsDisposed = | ||
}; | ||
private readonly drainQueue: SchedulerContinuationLike = shouldYield => { | ||
@@ -197,3 +131,64 @@ for ( | ||
}; | ||
constructor(hostScheduler: SchedulerLike) { | ||
this.disposable = createSerialDisposable(); | ||
this.hostScheduler = hostScheduler; | ||
this.disposable.add(() => this.queue.clear()); | ||
} | ||
get inScheduledContinuation(): boolean { | ||
return this.currentTask !== undefined; | ||
} | ||
get isDisposed(): boolean { | ||
return this.disposable.isDisposed; | ||
} | ||
get now(): number { | ||
return this.hostScheduler.now; | ||
} | ||
add( | ||
disposable: DisposableOrTeardown, | ||
...disposables: DisposableOrTeardown[] | ||
) { | ||
this.disposable.add(disposable, ...disposables); | ||
} | ||
dispose() { | ||
this.disposable.dispose(); | ||
} | ||
remove( | ||
disposable: DisposableOrTeardown, | ||
...disposables: DisposableOrTeardown[] | ||
) { | ||
this.disposable.remove(disposable, ...disposables); | ||
} | ||
schedule( | ||
continuation: SchedulerContinuationLike, | ||
priority: number, | ||
delay = 0, | ||
): DisposableLike { | ||
const startTime = this.now; | ||
const dueTime = startTime + delay; | ||
const task = { | ||
taskID: this.taskIDCounter++, | ||
continuation, | ||
disposable: createDisposable(), | ||
priority, | ||
startTime, | ||
dueTime, | ||
}; | ||
this.queue.push(task); | ||
this.scheduleDrainQueue(task); | ||
this.add(task.disposable); | ||
task.disposable.add(() => this.remove(task.disposable)); | ||
return task.disposable; | ||
} | ||
private scheduleDrainQueue(task: ScheduledTaskLike) { | ||
@@ -200,0 +195,0 @@ const head = this.queue.peek(); |
@@ -11,3 +11,2 @@ import { DisposableLike } from "@reactive-js/disposable"; | ||
private readonly priorityScheduler: PrioritySchedulerLike; | ||
constructor(priorityScheduler: PrioritySchedulerLike, priority: number) { | ||
@@ -14,0 +13,0 @@ this.priorityScheduler = priorityScheduler; |
@@ -39,4 +39,4 @@ import { | ||
implements VirtualTimeSchedulerResourceLike { | ||
private _now = 0; | ||
private readonly disposable = createDisposable(); | ||
private _now = 0; | ||
private readonly maxMicroTaskTicks: number; | ||
@@ -48,2 +48,6 @@ private microTaskTicks = 0; | ||
> = createPriorityQueue(comparator); | ||
constructor(maxMicroTaskTicks: number) { | ||
super(); | ||
this.maxMicroTaskTicks = maxMicroTaskTicks; | ||
} | ||
@@ -58,7 +62,2 @@ get isDisposed(): boolean { | ||
constructor(maxMicroTaskTicks: number) { | ||
super(); | ||
this.maxMicroTaskTicks = maxMicroTaskTicks; | ||
} | ||
add( | ||
@@ -65,0 +64,0 @@ disposable: DisposableOrTeardown, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
88301
+ Added@reactive-js/disposable@0.0.3(transitive)
+ Added@reactive-js/scheduler@0.0.3(transitive)
- Removed@reactive-js/disposable@0.0.2(transitive)
- Removed@reactive-js/scheduler@0.0.2(transitive)