igniteui-react-core
Version:
Ignite UI React Core.
253 lines (252 loc) • 8.16 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { Base, runOn, typeCast, markType } from "./type";
import { AsyncDataSourcePageRequest } from "./AsyncDataSourcePageRequest";
import { WeakReference } from "./WeakReference";
import { IDataSourceExecutionContext_$type } from "./IDataSourceExecutionContext";
import { LinkedList$1 } from "./LinkedList$1";
import { List$1 } from "./List$1";
/**
* @hidden
*/
export let AsyncVirtualDataSourceProviderWorker = /*@__PURE__*/ (() => {
class AsyncVirtualDataSourceProviderWorker extends Base {
constructor(a) {
super();
this.r = new LinkedList$1(AsyncDataSourcePageRequest.$);
this.p = new List$1(AsyncDataSourcePageRequest.$, 0);
this.ac = {};
this.i = true;
this.u = 0;
this.t = 0;
this.v = 0;
this.e = null;
this.s = -1;
this.as = null;
this.aq = null;
this.ar = null;
this.h = false;
this._isShutdown = false;
this.g = false;
this.i = true;
this.u = a.pageSizeRequested;
this.t = this.u;
this.v = a.timeoutMilliseconds;
this.as = new WeakReference(a.pageLoaded);
this.aq = new WeakReference(a.batchCompleted);
this.ar = new WeakReference(a.executionContext);
}
get tasks() {
return this.p;
}
get pageLoaded() {
if (this.as == null) {
return null;
}
return this.as.c;
}
get batchCompleted() {
if (this.aq == null) {
return null;
}
return this.aq.c;
}
get executionContext() {
if (this.ar == null) {
return null;
}
return this.ar.c;
}
get actualPageSize() {
return this.t;
}
set actualPageSize(a) {
this.t = a;
}
get actualCount() {
return this.s;
}
set actualCount(a) {
this.s = a;
}
get actualSchema() {
return this.e;
}
set actualSchema(a) {
this.e = a;
}
get populatedActualPageSize() {
return this.h;
}
set populatedActualPageSize(a) {
this.h = a;
}
get isRunning() {
return this.i;
}
set isRunning(a) {
this.i = a;
}
addPageRequest(a, b) {
return this.addPageRequestWithRetry(a, b, 200);
}
addPageRequestWithRetry(a, b, c) {
if (this.isShutdown) {
return false;
}
if (b == 2) {
this.r.e(new AsyncDataSourcePageRequest(a, c));
}
else {
this.r.f(new AsyncDataSourcePageRequest(a, c));
}
return true;
}
removePageRequest(a) {
let b = null;
let c = this.r.c;
while (c != null) {
let d = c.c;
if (d.index == a) {
b = c;
break;
}
c = c.a;
}
if (b != null) {
this.r.h(b);
}
}
get isShutdown() {
return this._isShutdown;
}
set isShutdown(a) {
this._isShutdown = a;
}
removeAllPageRequests() {
this.r.g();
}
shutdown() {
this.as = null;
this.aq = null;
this.ar = null;
this.isShutdown = true;
this.i = false;
}
initialize() {
}
getTaskDataHolder() {
return null;
}
getTasksData(a) {
}
removeCompletedTaskData(a, b) {
}
getCompletedTaskData(a, b) {
}
runATask() {
for (let a = 0; a < this.p.count; a++) {
if (!this.p.item(a).taskHolder.task.isRunning && !this.p.item(a).isDone && !this.p.item(a).taskHolder.task.isCompleted && !this.p.item(a).taskHolder.task.isCancelled) {
this.p.item(a).taskHolder.task.isRunning = true;
this.p.item(a).taskHolder.task.run();
break;
}
}
}
checkAndPotentiallyWaitOnTasks(a) {
this.runATask();
for (let b = 0; b < a.length; b++) {
if (a[b].isDone || a[b].taskHolder.task.isCompleted || a[b].taskHolder.task.isCancelled) {
return b;
}
}
return -1;
}
doWork() {
if (!this.g) {
this.g = true;
this.initialize();
}
{
let a = null;
let b = null;
let c = this.p.count;
if (this.r.c != null && c < 2) {
let d = this.r.c;
this.r.i();
this.makeTaskForRequest(d.c, d.c.retryDelay);
c = this.p.count;
}
if (c > 0) {
a = new Array(c);
for (let e = 0; e < c; e++) {
a[e] = this.p.item(e);
}
b = this.getTaskDataHolder();
this.getTasksData(b);
}
if (a != null && a.length > 0) {
let f = this.checkAndPotentiallyWaitOnTasks(a);
if (!this.i) {
return;
}
if (f >= 0) {
let g = a[f];
this.getCompletedTaskData(b, f);
this.p.remove(g);
this.removeCompletedTaskData(b, f);
this.processCompletedTask(g.taskHolder, g.retryDelay, g.index, b);
}
}
else {
}
if (!this.i) {
return;
}
if (this.i) {
window.setTimeout(runOn(this, this.doWork), 100);
}
}
}
makeTaskForRequest(a, b) {
}
processCompletedTask(a, b, c, d) {
}
retryIndex(a, b) {
let c = b * 2;
if (b > 20000) {
this.removePageRequest(a);
}
if (this.ar == null) {
this.shutdown();
return;
}
let d = typeCast(IDataSourceExecutionContext_$type, this.ar.c);
if (d == null) {
this.shutdown();
return;
}
d.executeDelayed(() => this.addPageRequestWithRetry(a, 0, c), b);
}
isLastPage(a) {
if (this.s < 0) {
return false;
}
if ((this.s - (a * this.t)) < this.t) {
return true;
}
return false;
}
createBatchRequest(a) {
}
}
AsyncVirtualDataSourceProviderWorker.$t = /*@__PURE__*/ markType(AsyncVirtualDataSourceProviderWorker, 'AsyncVirtualDataSourceProviderWorker');
AsyncVirtualDataSourceProviderWorker.maxSimultaneousExecutingTasks = 2;
AsyncVirtualDataSourceProviderWorker.maxRetryDelay = 20000;
AsyncVirtualDataSourceProviderWorker.initialRetryDelay = 200;
return AsyncVirtualDataSourceProviderWorker;
})();