diff --git a/static_core/plugins/ets/stdlib/escompat/taskpool.ets b/static_core/plugins/ets/stdlib/escompat/taskpool.ets index 47dc4d99c42c33c3ca117a1bb98ffef717a81300..428e2c5d717c7cb72b46c57258846f2b7725cc60 100644 --- a/static_core/plugins/ets/stdlib/escompat/taskpool.ets +++ b/static_core/plugins/ets/stdlib/escompat/taskpool.ets @@ -15,7 +15,19 @@ package escompat; -import {launch} from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + }; export namespace taskpool { class TaskPoolWorker extends EAWorker { @@ -42,7 +54,7 @@ export namespace taskpool { } let p = Promise.resolve(new Object()).then(taskRunner, taskRunner); p.then((res: NullishType) => { - task?.resolve(res); + task?.resolve(res); this.notifyTaskFinished(task) }).catch((e) => { task?.reject(e); @@ -247,7 +259,7 @@ export namespace taskpool { } if (!this.isDependent) { throw new Error("taskpool:: task has no dependency"); - } + } if (this.isSubmitted) { throw new Error("taskpool:: executedTask cannot removeDependency"); } @@ -1438,9 +1450,7 @@ export namespace taskpool { * @param priority task execution priority */ function launchImpl(task: Task, priority?: Priority): Promise { - const job: Job = launch NullishType>( - task.execute - ); + const job: Job = launch(task.execute) as Job; let promise = new Promise((resolve, reject) => { try { let res = job.Await(); @@ -1504,6 +1514,6 @@ function launchPromise(f: Function, ...args: FixedArray): Promise void>(cb) + launch(cb) return p; } diff --git a/static_core/plugins/ets/stdlib/std/concurrency/AsyncLock.ets b/static_core/plugins/ets/stdlib/std/concurrency/AsyncLock.ets index b40b94e41c443bc7095d774b094e1bdccae007d3..8f6998b2f339d1dde58127b54161693488f4ebf0 100644 --- a/static_core/plugins/ets/stdlib/std/concurrency/AsyncLock.ets +++ b/static_core/plugins/ets/stdlib/std/concurrency/AsyncLock.ets @@ -105,11 +105,11 @@ export final class AsyncLock { rejecter!(e) } } - launch void>(cb) + launch(cb) return p; } - private wrapper(callback: AsyncLockCallback, callerCID: int, mode: AsyncLockMode, options: AsyncLockOptions) : Promise { + private wrapper(callback: AsyncLockCallback, callerCID: int, mode: AsyncLockMode, options: AsyncLockOptions): Promise { let asyncLockInfo = new AsyncLockInfo(this.name, mode, callerCID); ConcurrencyHelpers.mutexLock(this.mutex); this.pending.add(asyncLockInfo); diff --git a/static_core/plugins/ets/stdlib/std/concurrency/ConcurrencyHelpers.ets b/static_core/plugins/ets/stdlib/std/concurrency/ConcurrencyHelpers.ets index d638ef6e2041d719095e1cdf2fef6b0d2196777a..17a746d3ab721fc3d0de431cf5b0c6e34cd99b07 100644 --- a/static_core/plugins/ets/stdlib/std/concurrency/ConcurrencyHelpers.ets +++ b/static_core/plugins/ets/stdlib/std/concurrency/ConcurrencyHelpers.ets @@ -15,7 +15,6 @@ package std.concurrency; -import { launch } from "std/concurrency" /// This class provides api for sync primitives (see SyncPrimitives.ets) final class ConcurrencyHelpers { @@ -41,8 +40,8 @@ class NativeAsyncWorkHelper { NativeAsyncWorkHelper.queueInternal(executeCb, completeCb, data); } static async queueInternal(executeCb: long, completeCb: long, data: long) { - let p = launch void>(NativeAsyncWorkHelper.asyncWorkNativeInvokeInternal, executeCb, data, true); - p.Await(); + let p = launch(NativeAsyncWorkHelper.asyncWorkNativeInvokeInternal, executeCb, data, true); + p!.Await(); NativeAsyncWorkHelper.asyncWorkNativeInvokeInternal(completeCb, data, false); } static native asyncWorkNativeInvoke(nativeCb: long, data: long, needNativeScope: boolean): void; diff --git a/static_core/plugins/ets/stdlib/std/concurrency/Launch.ets b/static_core/plugins/ets/stdlib/std/concurrency/Launch.ets index ef3e19eaa048f6c4cdc07901495265dfac026829..ec6321ac0616531294948e5f633617b7da2da52c 100644 --- a/static_core/plugins/ets/stdlib/std/concurrency/Launch.ets +++ b/static_core/plugins/ets/stdlib/std/concurrency/Launch.ets @@ -15,25 +15,6 @@ package std.concurrency; -type CoroFunT = ( - a0: A, - a1: A, - a2: A, - a3: A, - a4: A, - a5: A, - a6: A, - a7: A, - a8: A, - a9: A, - a10: A, - a11: A, - a12: A, - a13: A, - a14: A, - a15: A -) => R; - /** * This function is used to launch new coroutines. * @@ -42,7 +23,7 @@ type CoroFunT = ( * * @returns instance of the Job class that represents newly launched coroutine. */ -export function launch>(coroFun: F, ...args: FixedArray): Job { +function launch(coroFun: F, ...args: FixedArray): Job { return launchInternal(coroFun, args as FixedArray); } @@ -55,7 +36,7 @@ export function launch>(coroFun: F, ...args: Fix // return launchInternal(coroFun, launchParams, args as NullishType[]) // } -function launchInternal>(coroFun: F, args: FixedArray): Job { +function launchInternal(coroFun: F, args: FixedArray): Job { const paddedArgs = padArrayToMaxArgs(args); return launchInternalJobNative(coroFun, args as FixedArray); } diff --git a/static_core/plugins/ets/stdlib/std/core/EAWorker.ets b/static_core/plugins/ets/stdlib/std/core/EAWorker.ets index 4a01c10b91703a3e603580c63b4901e9aedc984b..e3a9d049609933a2e19020a00ad6891eef61a74b 100644 --- a/static_core/plugins/ets/stdlib/std/core/EAWorker.ets +++ b/static_core/plugins/ets/stdlib/std/core/EAWorker.ets @@ -15,7 +15,6 @@ package std.core; -import { launch } from "std/concurrency"; type Task = () => void; @@ -174,13 +173,27 @@ class StaticWorker implements InternalWorker { this.tasks.push(StaticWorker.closingTask); } + private body() { + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + }; while (true) { let task = this.tasks.pop(); if (task === StaticWorker.closingTask) { break; } - launch void>(task); + launch(task); } } } diff --git a/static_core/plugins/ets/stdlib/std/core/Method.ets b/static_core/plugins/ets/stdlib/std/core/Method.ets index 22921d01cb642ca1ad79d26962b2ce866fe7513a..f8c21cdd41842c45e848d8d58e9ad6d177f464f5 100644 --- a/static_core/plugins/ets/stdlib/std/core/Method.ets +++ b/static_core/plugins/ets/stdlib/std/core/Method.ets @@ -27,7 +27,7 @@ export final class Method extends Object { private attributes: int private accessMod: byte - private constructor () {} + private constructor() { } /** * Returns function type of this method @@ -87,7 +87,20 @@ export final class Method extends Object { } let convertedArgs: FixedArray = new NullishType[args.length] for (let i = 0; i < convertedArgs.length; i++) { - convertedArgs[i] = thisType.getParameter(i).getType().convertObject(args[i]) + if (args[i] instanceof Object[]) { + let p = args[i] as Object[]; + if (p.length == 0) { + convertedArgs[i] = thisType.getParameter(i).getType().convertObject(args[i]) + } else { + let arr: FixedArray = new NullishType[p.length]; + for (let j = 0; j < arr.length; ++j) { + arr[j] = p[j]; + } + convertedArgs[i] = arr; + } + } else { + convertedArgs[i] = thisType.getParameter(i).getType().convertObject(args[i]) + } } if (isCtor) { return TypeAPIMethodInvokeConstructor(this.methodType!, convertedArgs) @@ -109,9 +122,9 @@ export final class Method extends Object { public equals(oth: NullishType): boolean { return oth instanceof Method && - this.methodType!.equals((oth as Method).methodType!) && - this.name == (oth as Method).name && - this.accessMod == (oth as Method).accessMod && - this.attributes == (oth as Method).attributes + this.methodType!.equals((oth as Method).methodType!) && + this.name == (oth as Method).name && + this.accessMod == (oth as Method).accessMod && + this.attributes == (oth as Method).attributes } } diff --git a/static_core/plugins/ets/tests/checked/ets_promise_launch.ets b/static_core/plugins/ets/tests/checked/ets_promise_launch.ets index 5dd02e73bc7a3916207a451df82a86b3827b95e8..48a9e6af6d180a538e8c78d332fc8d1115c64bb7 100644 --- a/static_core/plugins/ets/tests/checked/ets_promise_launch.ets +++ b/static_core/plugins/ets/tests/checked/ets_promise_launch.ets @@ -22,11 +22,23 @@ //! SKIP_IF @architecture == "arm32" //! RUN_PAOC options: "--compiler-regex='.*main.*'" -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + function main(): int { for (let i = 0; i < 100; i++) { - let r = launch number>(((p: number): number => p + p), 42.0) + let r = launch(((p: number): number => p + p), 42.0) as Job assertEQ((r.Await()), 84.0); } return 0; diff --git a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_compare_exchange.ets b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_compare_exchange.ets index 2435ac071785d24e24c6473274003e95b6eeeedb..431be967666623ca88b2ebbc37cd4636aa5ff7c7 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_compare_exchange.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_compare_exchange.ets @@ -14,7 +14,6 @@ */ import { StdDebug } from "std/debug" -import { launch } from "std/concurrency" type L = StdDebug.Logger @@ -28,16 +27,28 @@ function main() { buf_2 = new ArrayBuffer(4); arr = new Int8Array(buf, 0, 1); arr_2 = new Int32Array(buf_2, 0, 1); + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } + } for (let i = 0; i < 5; i++) { - launch Int>(worker_i8, i as byte) + launch(worker_i8, i as byte) } while (Atomics.load(arr, 0) != 5) { } L.log("Finished for Int8Array") for (let i = 0; i < 5; i++) { - launch Int>(worker_i32, i as int) + launch(worker_i32, i as int) } while (Atomics.load(arr_2, 0) != 5) { } diff --git a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_countdownlatch.ets b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_countdownlatch.ets index 5895c808e2413af8a3f64085049e8a91355345ee..bc89620cfb3730eb15e3bcb4060a572b0e72f825 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_countdownlatch.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_countdownlatch.ets @@ -14,7 +14,6 @@ */ import {StdDebug} from "std/debug" -import { launch } from "std/concurrency" type L = StdDebug.Logger @@ -34,9 +33,21 @@ function main() { arr_2 = new BigInt64Array(buf_2, 0, 1) bytearr_i8 = new Int8Array(buf_1, 0, 4) bytearr_i64 = new BigInt64Array(buf_2, 0, 1) + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } + } for (let i = 0; i < N; i++) { - launch Int>(task_1) + launch(task_1) } let cur: byte = Atomics.load(bytearr_i8, 0) as byte while (cur != N) { @@ -46,7 +57,7 @@ function main() { } for (let i = 0; i < N; i++) { - launch Int>(task_2) + launch(task_2) } let cur_64: long = Atomics.load(bytearr_i64, 0).getLong() while (cur_64 != N) { diff --git a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_increment.ets b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_increment.ets index 3026f50a053b3d209cdba25b1cb58c787e9a7457..df8075e68a6a257a34ec2032a3d3236959b506f8 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_increment.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_increment.ets @@ -13,7 +13,6 @@ * limitations under the License. */ - import { launch } from "std/concurrency" let N = 200 let RESULT = N as byte @@ -28,12 +27,26 @@ function main() { arr_u32 = new Int32Array(buf_2, 0, 1); arr_u32[0] = N - launch Int>(incrementer) + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + }; + + launch(incrementer) while (Atomics.load(arr, 0) != RESULT) { wait() } - launch Int>(decrementer) + launch(decrementer) while (Atomics.load(arr_u32, 0) != 0) { wait() } diff --git a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_store_load.ets b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_store_load.ets index 300a483807836e5b4f7675f2ac9fb06b4c81c096..34a0f23ac3f341e1f8cf7790b0ccf9a0995355ec 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_store_load.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_store_load.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { launch } from "std/concurrency" + let RESULT = 10 as long @@ -22,8 +22,21 @@ let arr: BigInt64Array = new BigInt64Array; function main() { let buf = new ArrayBuffer(8); arr = new BigInt64Array(buf, 0, 1); - - launch Int>(incrementer) + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + }; + + launch(incrementer) while (Atomics.load(arr, 0).getLong() != RESULT) { wait() diff --git a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_wait_store_notify.ets b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_wait_store_notify.ets index 4f9325090a09f02087d3e41b6f8bdc28a5a576b3..ea83eeae25e9a819e343a43344eb3609715dabac 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_wait_store_notify.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/atomics/concurrent_wait_store_notify.ets @@ -17,11 +17,22 @@ // 2. "0 not-equal": store -> wait -> notify, or store -> notify -> wait // All other outputs are invalid -import { launch } from "std/concurrency" let buf: ArrayBuffer = new ArrayBuffer(0); let arr: Int32Array = new Int32Array; let bytearr: Int8Array = new Int8Array; +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } +} function main() { let c = new Console() @@ -30,7 +41,8 @@ function main() { arr = new Int32Array(buf, 0, 1); bytearr = new Int8Array(buf, 0, 4) - launch Int>(writer) + + launch(writer) let res = Atomics.wait(arr, 0, new BigInt(0)) as string c.println(res) diff --git a/static_core/plugins/ets/tests/ets-common-tests/atomics/skipped_cyclic_barrier.ets b/static_core/plugins/ets/tests/ets-common-tests/atomics/skipped_cyclic_barrier.ets index a06ed0cb8b102793cdcc93e3932d31dac5784714..e15aff2a935074c3942d22754b7f96dad926d12e 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/atomics/skipped_cyclic_barrier.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/atomics/skipped_cyclic_barrier.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" let s = new ArrayBuffer(4); @@ -23,9 +22,22 @@ let N = 5 function main() { let corArrayTmp = new Array>>(); + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } + } + setUpBarrier(N) for (let i = 0; i < N; i++) { - let job = launch Int>(task) + let job = launch(task) as Job; corArrayTmp.push(job); } for (let i = 0; i < N; i++) { diff --git a/static_core/plugins/ets/tests/ets-common-tests/atomics/skipped_rendezvous_channel.ets b/static_core/plugins/ets/tests/ets-common-tests/atomics/skipped_rendezvous_channel.ets index 69a47a9e12b5bde28c4c07fa351e2dc83984e9e7..b546ee914695e0b698c189f1825f4b79b90c5fdc 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/atomics/skipped_rendezvous_channel.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/atomics/skipped_rendezvous_channel.ets @@ -13,15 +13,27 @@ * limitations under the License. */ -import { launch } from "std/concurrency" let s = new ArrayBuffer(4); let arr = new Int32Array(s, 0, 1); function main() { - let consumerJob = launch Int>(consumer) + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } + } + + let consumerJob = launch(consumer) heavyComputation() - let producerJob = launch Int>(producer) + let producerJob = launch(producer) producerJob.Await(); consumerJob.Await(); diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/to_string_cache.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/to_string_cache.ets index b846d27e71e352a9ea184b0d875c4fa8e525cc50..909df4439d411b6de9baf1ad54a2d1141640664a 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/to_string_cache.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/to_string_cache.ets @@ -13,9 +13,21 @@ * limitations under the License. */ -import {launch} from "std/concurrency" import {Job} from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + // simple fast pseudo-random generator function xorshift(state: long): long { state ^= state << 13; @@ -150,7 +162,7 @@ function doTest(values: T[], workers: int) { const work = (w: Worker, s: long, i: int, c: boolean) => { return w.work(s, i, c); } - jobs[i] = launch, s: long, i: int, c: boolean) => string>(work, worker, state, iterCount, check); + jobs[i] = launch(work, worker, state, iterCount, check) as Job; } for (let i = 0; i < workers; i++) { let res = jobs[i]!.Await(); diff --git a/static_core/plugins/ets/tests/ets-common-tests/taskpool/common_tasks.ets b/static_core/plugins/ets/tests/ets-common-tests/taskpool/common_tasks.ets index a905bc1143587ecf743202cd786ca7b9dfdb0c9c..d90f0d63e056c6ee60d343da8b66d159fa5614bb 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/taskpool/common_tasks.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/taskpool/common_tasks.ets @@ -68,9 +68,22 @@ function delayWithYield(duration: int): void { } function launchImpl(func: () => NullishType): Promise { - const job: Job = launch NullishType>( + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + } + const job: Job = launch( func - ); + ) as Job; return new Promise((resolve, reject) => { try { let res = job.Await(); diff --git a/static_core/plugins/ets/tests/ets-common-tests/taskpool/group_tasks.ets b/static_core/plugins/ets/tests/ets-common-tests/taskpool/group_tasks.ets index 3a189b600dbb86b1b26da0c468b419a93ddefbf6..b0725b90dade8fe470047f2c5e7fe90ad7d4395e 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/taskpool/group_tasks.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/taskpool/group_tasks.ets @@ -36,9 +36,22 @@ function delayWithYield(duration: int): void { } function launchImpl(func: () => NullishType): Promise { - const job: Job = launch NullishType>( + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + } + const job: Job = launch( func - ); + ) as Job; return new Promise((resolve, reject) => { try { let res = job.Await(); diff --git a/static_core/plugins/ets/tests/ets-common-tests/taskpool/long_task.ets b/static_core/plugins/ets/tests/ets-common-tests/taskpool/long_task.ets index 500e3e8095ca75312b12212672c3f92fc20fd11c..992e5dfb916dc426dda57af0ace8e72ebe97888d 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/taskpool/long_task.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/taskpool/long_task.ets @@ -33,9 +33,22 @@ function delayWithYield(duration: int): void { } function launchImpl(func: () => NullishType): Promise { - const job: Job = launch NullishType>( + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + } + const job: Job = launch( func - ); + ) as Job; return new Promise((resolve, reject) => { try { let res = job.Await(); diff --git a/static_core/plugins/ets/tests/ets-common-tests/taskpool/seqrunner_tasks.ets b/static_core/plugins/ets/tests/ets-common-tests/taskpool/seqrunner_tasks.ets index 8cc5c7a3e594b855c2769074d5d686d95fdcf2ab..bc44e26966ccd6d8814c640ba99fb26929be885c 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/taskpool/seqrunner_tasks.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/taskpool/seqrunner_tasks.ets @@ -32,9 +32,22 @@ function delayWithYield(duration: int): void { } function launchImpl(func: () => NullishType): Promise { - const job: Job = launch NullishType>( + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + } + const job: Job = launch( func - ); + ) as Job; return new Promise((resolve, reject) => { try { let res = job.Await(); diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/WeakMapGCTest.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/WeakMapGCTest.ets index b4261980d85b3085fc7af17bd5bfec7428367b3e..3708710ffe611c41e08c62e70ef69d555bd1c750 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/WeakMapGCTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/WeakMapGCTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + class Key { readonly id: int @@ -75,7 +87,7 @@ function weakMapKeyGarbageCollection(): void { reclaimedKeyId = NULL_ID // using coroutine to avoid WeakMap creation function inlining - const weakMapCreator = launch< WeakMap, (keyId: int) => WeakMap>(createTestWeakMap, KEY_ID) + const weakMapCreator = launch(createTestWeakMap, KEY_ID) as Job> const weakMap = weakMapCreator.Await() while (reclaimedKeyId != KEY_ID) { diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/WeakSetGCTest.ets b/static_core/plugins/ets/tests/ets_func_tests/escompat/WeakSetGCTest.ets index 7f4964127ed1f830533497b77aa10bb82b7862cf..7ef53dce6ceaecfc44ce171e1b341a91f05a003e 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/escompat/WeakSetGCTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/escompat/WeakSetGCTest.ets @@ -13,7 +13,20 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + } + class Key { readonly id: int @@ -67,7 +80,7 @@ function weakSetElementGarbageCollection(): void { reclaimedElemId = NULL_ID // using coroutine to avoid WeakSet creation function inlining - const weakSetCreator = launch, (elemId: int) => WeakSet>(createTestWeakSet, ELEM_ID) + const weakSetCreator = launch(createTestWeakSet, ELEM_ID) as Job> const weakSet = weakSetCreator.Await() while (reclaimedElemId != ELEM_ID) { diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/BlockingQueue/LinkedBlockingQueue_getEnd.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/BlockingQueue/LinkedBlockingQueue_getEnd.ets index 3c25eb9153cddb8aa9e3000e9a20729aea3f4eee..ed29d644f2115a68963015a764d379aaa1150b8b 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/BlockingQueue/LinkedBlockingQueue_getEnd.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/BlockingQueue/LinkedBlockingQueue_getEnd.ets @@ -13,6 +13,19 @@ * limitations under the License. */ +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + function main(): int { let LinkedBlockingQueueTestsuite = new ArkTestsuite("LinkedBlockingQueueGetEndTest") LinkedBlockingQueueTestsuite.addTest("getEndFill", getEndFillTest) @@ -86,7 +99,7 @@ function getEndConcurrentTest() { let lock = new AsyncLock() let jobs: Job>[] = [] for (let i = 0; i < JOB_COUNT; i++) { - jobs.push(launch, (a0: LinkedBlockingQueue, a1: AsyncLock, a2: AtomicFlag) => Promise>(getEndConcurrent, testBlockingQueue, lock, flag)) + jobs.push(launch(getEndConcurrent, testBlockingQueue, lock, flag) as Job>) } for (let i = 0; i < JOB_COUNT; i++) { jobs[i].Await() diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_AddTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_AddTest.ets index c80d8dd66a481227b45b63503e2fe6bffe0a1711..6ef13b991ce2d2a69ab2b719e4bcd67561ed89b9 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_AddTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_AddTest.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { launch } from "std/concurrency" const elementsNum: int = 100; let b1: int | null = 0; @@ -22,6 +21,20 @@ let f1: int | null = 0; let queueInt: ArrayBlockingQueue = new ArrayBlockingQueue(200); let queueIntPopN: ArrayBlockingQueue = new ArrayBlockingQueue(200); +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + } + function main(): int { let ArrayBlockingQueueTestsuite = new ArkTestsuite("ArrayBlockingQueueAddTest"); @@ -47,10 +60,10 @@ function main(): int { while (!queueIntPopN.isEmpty()) { queueIntPopN.pop(); } - let p1 = launch void>(queueIntAdddata); - let p2 = launch void>(queueIntAdddata); - let p3 = launch void>(queueIntAdddata); - let p4 = launch void>(queueIntAdddata); + let p1 = launch(queueIntAdddata) as Job; + let p2 = launch(queueIntAdddata) as Job; + let p3 = launch(queueIntAdddata) as Job; + let p4 = launch(queueIntAdddata) as Job; p1.Await(); p2.Await(); p3.Await(); @@ -65,7 +78,7 @@ function main(): int { for (let i: int = 0; i < elementsNum; ++i) { queueInt.add(i); } - let p1 = launch void>(queueIntFrontF1data); + let p1 = launch(queueIntFrontF1data) as Job; p1.Await(); assertEQ(queueInt.size, elementsNum); }); @@ -77,7 +90,7 @@ function main(): int { for (let i: int = 0; i < elementsNum; ++i) { queueInt.add(i); } - let p1 = launch void>(queueIntBackB1data); + let p1 = launch(queueIntBackB1data) as Job; p1.Await(); assertFalse(queueInt.isEmpty()); }); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetEndTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetEndTest.ets index e0bc016aa6f9fb440d639c324422bf53062021ba..a303b0b350c11d23e6f8ec89ea7544428dba6fab 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetEndTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetEndTest.ets @@ -13,8 +13,20 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + }; const elementsNum: int = 100; let b1: int | null = 0; let b2: int | null = 0; @@ -45,7 +57,7 @@ function main(): int { assertEQ(el, queueInt.pop()); } assertEQ(queueInt.size, 0); - let p1 = launch void>(queueIntGetEnddata); + let p1 = launch(queueIntGetEnddata) as Job; queueInt.push(elementsNum); p1.Await(); assertEQ(queueInt.size, 1); @@ -66,7 +78,7 @@ function main(): int { assertEQ(el, queueInt.pop()); } assertEQ(queueInt.size, 0); - let p1 = launch void>(queueIntGetEnddata); + let p1 = launch(queueIntGetEnddata) as Job; queueInt.push(elementsNum); p1.Await(); assertEQ(queueInt.size, 1); @@ -87,7 +99,7 @@ function main(): int { assertEQ(el, queueInt.pop()); } assertEQ(queueInt.size, 0); - let p1 = launch void>(queueIntGetEnddata); + let p1 = launch(queueIntGetEnddata) as Job; let a1: int = 10; let a2: int = 20; queueInt.push(a1); @@ -100,10 +112,10 @@ function main(): int { while (!queueInt.isEmpty()) { queueInt.pop(); } - let p1 = launch void>(queueIntGetEndB1data); - let p2 = launch void>(queueIntAddTwodata); - let p3 = launch void>(queueIntGetEndB2data); - let p4 = launch void>(queueIntAddTwodata); + let p1 = launch(queueIntGetEndB1data) as Job; + let p2 = launch(queueIntAddTwodata) as Job; + let p3 = launch(queueIntGetEndB2data) as Job; + let p4 = launch(queueIntAddTwodata) as Job; p1.Await(); p2.Await(); p3.Await(); @@ -116,12 +128,12 @@ function main(): int { queueInt.pop(); } queueInt.push(10); - let p1 = launch void>(queueIntGetEnddata); - let p2 = launch void>(queueIntGetEnddata); + let p1 = launch(queueIntGetEnddata) as Job; + let p2 = launch(queueIntGetEnddata) as Job; queueInt.push(20); p1.Await(); p2.Await(); - let p3 = launch void>(queueIntGetEnddata); + let p3 = launch(queueIntGetEnddata) as Job; p3.Await(); assertEQ(queueInt.getEnd(), 20); }); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetFirstTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetFirstTest.ets index 1d0a11debcd4719b29826d1326bfd4ed75a433e5..9d6a0f910aae079816ee993c413c4ef99b00073f 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetFirstTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetFirstTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + } const elementsNum: int = 10; const stressNum: int = 100; @@ -128,7 +140,7 @@ function main(): int { let el = queueInt.getFirst(); assertEQ(el, queueInt.pop()); } - let p1 = launch void>(queueIntGetFirstdata); + let p1 = launch(queueIntGetFirstdata) as Job; let frontNum: int = 10; queueInt.push(frontNum); p1.Await(); @@ -149,7 +161,7 @@ function main(): int { assertEQ(el, queueInt.pop()); } assertEQ(queueInt.size, 0); - let p1 = launch void>(queueIntGetFirstdata); + let p1 = launch(queueIntGetFirstdata) as Job; let frontNum: int = 10; queueInt.push(frontNum); p1.Await(); @@ -161,11 +173,11 @@ function main(): int { while (!queueInt.isEmpty()) { queueInt.pop(); } - let p1 = launch void>(queueIntGetFirstF1data); + let p1 = launch(queueIntGetFirstF1data) as Job; queueInt.push(10); queueInt.push(20); p1.Await(); - let p2 = launch void>(queueIntGetEndB1data); + let p2 = launch(queueIntGetEndB1data) as Job; p2.Await(); assertEQ(queueInt.size, 2); }); @@ -177,9 +189,9 @@ function main(): int { queueInt.pop(); } assertTrue(queueInt.isEmpty()); - let p1 = launch void>(queueIntAddTwodata); - let p2 = launch void>(queueIntGetFirstF1data); - let p3 = launch void>(queueIntGetFirstF2data); + let p1 = launch(queueIntAddTwodata) as Job; + let p2 = launch(queueIntGetFirstF1data) as Job; + let p3 = launch(queueIntGetFirstF2data) as Job; p1.Await(); p2.Await(); p3.Await(); @@ -194,10 +206,10 @@ function main(): int { } queueInt.push(10); queueInt.push(30); - let p1 = launch void>(queueIntGetFirstdata); + let p1 = launch(queueIntGetFirstdata) as Job; queueInt.push(20); p1.Await(); - let p2 = launch void>(queueIntGetFirstdata); + let p2 = launch(queueIntGetFirstdata) as Job; p2.Await(); assertEQ(queueInt.getFirst(), 10); }); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetSizeTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetSizeTest.ets index 5aa2dc14b5c05c77fc551693e71c37dbd6cea01e..02abdacae21baad2209b6475a313532057cb8970 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetSizeTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_GetSizeTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + } const elementsNum: int = 100; let sizeNum: int = 0; @@ -31,10 +43,10 @@ function main(): int { for (let i: int = 0; i < elementsNum; ++i) { queueInt.push(i); } - let p1 = launch void>(queueIntSizedata); - let p2 = launch void>(queueIntSizedata); - let p3 = launch void>(queueIntSizedata); - let p4 = launch void>(queueIntSizedata); + let p1 = launch(queueIntSizedata) as Job; + let p2 = launch(queueIntSizedata) as Job; + let p3 = launch(queueIntSizedata) as Job; + let p4 = launch(queueIntSizedata) as Job; p1.Await(); p2.Await(); p3.Await(); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PollTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PollTest.ets index 108b61f90e6ecfb823878470332c0d83e1ffdfac..9fca325b03eeb6338a0dce3d0be31372028950a1 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PollTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PollTest.ets @@ -13,9 +13,22 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + }; + const elementsNum: int = 10; const stressNum: int = 100; @@ -63,7 +76,7 @@ function main(): int { let jobs = new Array>(100); let p = 0; for (let i = 0; i < stressNum; i++) { - jobs[p++] = launch void>(sQueuePollData); + jobs[p++] = launch(sQueuePollData) as Job; } for (let i: int = 0; i < 100; i++) { jobs[i].Await(); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PopTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PopTest.ets index 8d8d58eddc85f7ca31f5cc369f32ab2d45680ba4..1ee336a84b483e9c05544b2176de3a19aa79fe46 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PopTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PopTest.ets @@ -13,9 +13,22 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + } + const elementsNum: int = 100; let f1: int | null = 0; @@ -32,7 +45,7 @@ function main(): int { ArrayBlockingQueueTestsuite.addTest("ConcurrentPushPopTestStr", () => { - let p1 = launch void>(pusherStr); + let p1 = launch(pusherStr) as Job; let arrayToCheck = popperStr(); p1.Await(); for (let i = 0; i < elementsNum; i++) { @@ -65,14 +78,14 @@ function main(): int { let el = queueIntPop2.getFirst(); assertEQ(el, queueIntPop2.pop()); } - let p1 = launch) => void>(ArrayBlockingQueuePop, queueIntPop2); + let p1 = launch(ArrayBlockingQueuePop, queueIntPop2) as Job; let i = queueIntPop2.pop(); p1.Await(); assertEQ(i, 10); }); ArrayBlockingQueueTestsuite.addTest("PopTestInt003", () => { - let p1 = launch void>(queueIntPopNdata); + let p1 = launch(queueIntPopNdata) as Job; for (let i: int = 0; i < elementsNum; ++i) { queueIntPopN.push(i); } @@ -102,7 +115,7 @@ function main(): int { } let jobs = new Array>(100); for (let i: int = 0; i < elementsNum; ++i) { - jobs[i] = launch void>(queueIntPopdata); + jobs[i] = launch(queueIntPopdata) as Job; } for (let i: int = 0; i < elementsNum; ++i) { queueIntPopN.push(i); @@ -120,8 +133,8 @@ function main(): int { for (let i: int = 0; i < elementsNum; ++i) { queueInt.push(i); } - let p1 = launch void>(queueIntFrontF1data); - let p2 = launch void>(queueIntPopFdata); + let p1 = launch(queueIntFrontF1data) as Job; + let p2 = launch(queueIntPopFdata) as Job; p1.Await(); p2.Await(); assertEQ(queueInt.size, elementsNum - 1); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PushTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PushTest.ets index 542971fe950718191ac968e0b5863c15fb2fbaf3..2bf906cdfbfb8a47f84081a684054cddf8295232 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PushTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/array_blocking_queue/ArrayBlockingQueue_PushTest.ets @@ -13,7 +13,18 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } const elementsNum: int = 100; @@ -47,7 +58,7 @@ function main(): int { }); ArrayBlockingQueueTestsuite.addTest("ConcurrentPushPopTestInt", () => { - let p1 = launch void>(pusherInt); + let p1 = launch(pusherInt) as Job; let arrayToCheck = popperInt(); for (let i = 0; i < elementsNum; i++) { assertEQ(testArrayInt[i], arrayToCheck[i]); @@ -57,7 +68,7 @@ function main(): int { }); ArrayBlockingQueueTestsuite.addTest("ConcurrentPushPopTestObj", () => { - let p1 = launch void>(pusherObj); + let p1 = launch(pusherObj) as Job; let arrayToCheck = popperObj(); for (let i = 0; i < elementsNum; i++) { assertEQ(testArrayObj[i], arrayToCheck[i]); @@ -67,7 +78,7 @@ function main(): int { }); ArrayBlockingQueueTestsuite.addTest("ConcurrentPushPopTestStr", () => { - let p1 = launch void>(pusherStr); + let p1 = launch(pusherStr) as Job; let arrayToCheck = popperStr(); for (let i = 0; i < elementsNum; i++) { assertEQ(testArrayStr[i], arrayToCheck[i]); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/blocking_queue.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/blocking_queue.ets index 03e9d1391413b8057f9f0b8d0a6f3263cc0817a5..63209f5ee5259537a7c5ee781ec8ea0acc0f32f2 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/blocking_queue.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/blocking_queue.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + const elementsNum: int = 100; let testArrayInt: Array = new Array(elementsNum); @@ -104,7 +116,7 @@ function popperStr(): Array { } function concurrentPushPopTestInt() { - let p1 = launch void>(pusherInt); + let p1 = launch(pusherInt) as Job; p1.Await(); let arrayToCheck = popperInt(); for (let i = 0; i < elementsNum; i++) { @@ -114,7 +126,7 @@ function concurrentPushPopTestInt() { } function concurrentPushPopTestObj() { - let p1 = launch void>(pusherObj); + let p1 = launch(pusherObj) as Job; p1.Await(); let arrayToCheck = popperObj(); for (let i = 0; i < elementsNum; i++) { @@ -124,7 +136,7 @@ function concurrentPushPopTestObj() { } function concurrentPushPopTestStr() { - let p1 = launch void>(pusherStr); + let p1 = launch(pusherStr) as Job; p1.Await(); let arrayToCheck = popperStr(); for (let i = 0; i < elementsNum; i++) { diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ClearTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ClearTest.ets index c371557e6223646a4d61c2d2ff362488050899e7..7e538ef32130e607ad844e23024992b84c21158c 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ClearTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ClearTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; let arrValues: string[] = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; @@ -59,8 +71,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(removeAll); - let p2 = launch void>(clearAll); + let p1 = launch(removeAll) as Job; + let p2 = launch(clearAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_DeleteTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_DeleteTest.ets index b9667d5d4b6781af271263c8632b3bc4d1db63cf..b3cfe87f57ee1d1676c3cb0cb1e9c0512ee91e28 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_DeleteTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_DeleteTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let buf = new ArrayBuffer(4); let flag: Int8Array = new Int8Array(buf, 0, 4); @@ -79,8 +91,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>(deleteAllBack); + let p1 = launch(deleteAll) as Job; + let p2 = launch(deleteAllBack) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 0); @@ -91,8 +103,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>(replaceAll); + let p1 = launch(deleteAll) as Job; + let p2 = launch(replaceAll) as Job; p1.Await(); p2.Await(); assertTrue(Atomics.load(flag, 0) >= 10); @@ -103,8 +115,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>(isEmptyFun); + let p1 = launch(deleteAll) as Job; + let p2 = launch(isEmptyFun) as Job; p1.Await(); p2.Await(); assertEQ(Atomics.load(flag, 0), 10); @@ -114,8 +126,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>(clearAll); + let p1 = launch(deleteAll) as Job; + let p2 = launch(clearAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -126,8 +138,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(removeAll); - let p2 = launch void>(deleteAllBack); + let p1 = launch(removeAll) as Job; + let p2 = launch(deleteAllBack) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_EntriesTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_EntriesTest.ets index e54cab9d36f1fe656db3dc689a33edd2548be492..e41c149260005e638a5ff35640234a00e5113fb6 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_EntriesTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_EntriesTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; @@ -134,8 +146,8 @@ function main(): int { { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); - let p1 = launch void>(setAll); - let p2 = launch void>(entriesAll); + let p1 = launch(setAll) as Job; + let p2 = launch(entriesAll) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -145,8 +157,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>(entriesAll); + let p1 = launch(deleteAll) as Job; + let p2 = launch(entriesAll)as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -157,8 +169,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); setAll(); assertEQ(concurrentHashMapOne.size, 10); - let p1 = launch void>(entriesAll); - let p2 = launch void>(clearAll); + let p1 = launch(entriesAll) as Job; + let p2 = launch(clearAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ForEachTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ForEachTest.ets index 2ef376683ef5eec6f1f57b10ce52fa87531a48a9..b7840dde7f6fbfdbc3e04c5a6041d42140a8d434 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ForEachTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ForEachTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let buf = new ArrayBuffer(4); let flag: Int8Array = new Int8Array(buf, 0, 4); @@ -110,8 +122,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); - let p1 = launch void>(forEachZero); - let p2 = launch void>(setAll); + let p1 = launch(forEachZero) as Job; + let p2 = launch(setAll) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -123,8 +135,8 @@ function main(): int { Atomics.store(flag, 0, 0); del = 0; setAll(); - let p1 = launch void>(forEachZero); - let p2 = launch void>(deleteAllBack); + let p1 = launch(forEachZero) as Job; + let p2 = launch(deleteAllBack) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -135,8 +147,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(forEachZero); - let p2 = launch void>(getAll); + let p1 = launch(forEachZero) as Job; + let p2 = launch(getAll) as Job; p1.Await(); p2.Await(); assertEQ(Atomics.load(flag, 0), 10); @@ -147,8 +159,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(clearAll); - let p2 = launch void>(forEachZero); + let p1 = launch(clearAll) as Job; + let p2 = launch(forEachZero) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -158,8 +170,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); - let p1 = launch void>(setAll); - let p2 = launch void>(forEachOne); + let p1 = launch(setAll) as Job; + let p2 = launch(forEachOne) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -171,8 +183,8 @@ function main(): int { Atomics.store(flag, 0, 0); del = 0; setAll(); - let p1 = launch void>(deleteAllBack); - let p2 = launch void>(forEachOne); + let p1 = launch(deleteAllBack) as Job; + let p2 = launch(forEachOne) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -184,8 +196,8 @@ function main(): int { arrValuesTest = ["ten", "ten", "ten", "ten", "ten", "ten", "ten", "ten", "ten", "ten"]; Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(getAll); - let p2 = launch void>(forEachOne); + let p1 = launch(getAll) as Job; + let p2 = launch(forEachOne) as Job; p1.Await(); p2.Await(); for (let i: int = 0; i < 10; i++) { @@ -198,8 +210,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(clearAll); - let p2 = launch void>(forEachOne); + let p1 = launch(clearAll) as Job; + let p2 = launch(forEachOne) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -209,8 +221,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); - let p1 = launch void>(setAll); - let p2 = launch void>(forEachTwo); + let p1 = launch(setAll) as Job; + let p2 = launch(forEachTwo) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -222,8 +234,8 @@ function main(): int { Atomics.store(flag, 0, 0); del = 0; setAll(); - let p1 = launch void>(forEachTwo); - let p2 = launch void>(deleteAllBack); + let p1 = launch(forEachTwo) as Job; + let p2 = launch(deleteAllBack) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -236,8 +248,8 @@ function main(): int { arrValuesTest = ["ten", "ten", "ten", "ten", "ten", "ten", "ten", "ten", "ten", "ten"]; Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(getAll); - let p2 = launch void>(forEachTwo); + let p1 = launch(getAll) as Job; + let p2 = launch(forEachTwo) as Job; p1.Await(); p2.Await(); for (let i: int = 0; i < 10; i++) { @@ -253,8 +265,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(clearAll); - let p2 = launch void>(forEachTwo); + let p1 = launch(clearAll) as Job; + let p2 = launch(forEachTwo) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -264,8 +276,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); - let p1 = launch void>(setAll); - let p2 = launch void>(forEachThree); + let p1 = launch(setAll) as Job; + let p2 = launch(forEachThree) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -277,8 +289,8 @@ function main(): int { Atomics.store(flag, 0, 0); del = 0; setAll(); - let p1 = launch void>(forEachThree); - let p2 = launch void>(deleteAllBack); + let p1 = launch(forEachThree) as Job; + let p2 = launch(deleteAllBack) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -289,8 +301,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(getAll); - let p2 = launch void>(forEachThree); + let p1 = launch(getAll) as Job; + let p2 = launch(forEachThree) as Job; p1.Await(); p2.Await(); for (let i: int = 0; i < 10; i++) { @@ -306,8 +318,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(clearAll); - let p2 = launch void>(forEachThree); + let p1 = launch(clearAll) as Job; + let p2 = launch(forEachThree) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_GetTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_GetTest.ets index 585d5ba792af833de34b152cba8d317bc654bd9e..201314414ca00fca5ef43c033d440bf4f742f005 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_GetTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_GetTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let buf = new ArrayBuffer(4); let flag: Int8Array = new Int8Array(buf, 0, 4); @@ -72,8 +84,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(getAll); - let p2 = launch void>(getAll1); + let p1 = launch(getAll) as Job; + let p2 = launch(getAll1) as Job; p1.Await(); p2.Await(); let flagCounter: int = 0; @@ -92,8 +104,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(getAll); - let p2 = launch void>(hasAll); + let p1 = launch(getAll) as Job; + let p2 = launch(hasAll) as Job; p1.Await(); p2.Await(); let flagCounter: int = 0; @@ -111,8 +123,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(getAll); - let p2 = launch void>(deleteAllBack); + let p1 = launch(getAll) as Job; + let p2 = launch(deleteAllBack) as Job; p1.Await(); p2.Await(); for (let i = 0; i < 10; i++) { @@ -128,8 +140,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(replaceAll); - let p2 = launch void>(getAllBack); + let p1 = launch(replaceAll) as Job; + let p2 = launch(getAllBack) as Job; p1.Await(); p2.Await(); let flagCounter: int = 0; @@ -146,8 +158,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(getAll); - let p2 = launch void>(isEmptyFun); + let p1 = launch(getAll) as Job; + let p2 = launch(isEmptyFun) as Job; p1.Await(); p2.Await(); let flagCounter: int = 0; @@ -164,8 +176,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(getAll); - let p2 = launch void>(clearAll); + let p1 = launch(getAll) as Job; + let p2 = launch(clearAll) as Job; p1.Await(); p2.Await(); let flagCounter: int = 0; @@ -183,8 +195,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(getAll1); - let p2 = launch void>(removeAll); + let p1 = launch(getAll1) as Job; + let p2 = launch(removeAll) as Job; p1.Await(); p2.Await(); let flagCounter: int = 0; diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_HasTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_HasTest.ets index 5aed232869d9a56d4b6e0881b0d33d090faa66be..be3830ecdf1b482fa645b8f1b20301a5c4c3cfe0 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_HasTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_HasTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let buf = new ArrayBuffer(4); let flag: Int8Array = new Int8Array(buf, 0, 4); @@ -65,8 +77,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(hasAll); - let p2 = launch void>(hasAll); + let p1 = launch(hasAll) as Job; + let p2 = launch(hasAll) as Job; p1.Await(); p2.Await(); assertTrue(Atomics.load(flag, 0) >= 10); @@ -77,8 +89,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(hasAll); - let p2 = launch void>(deleteAllBack); + let p1 = launch(hasAll) as Job; + let p2 = launch(deleteAllBack) as Job; p1.Await(); p2.Await(); assertTrue(Atomics.load(flag, 0) >= 10); @@ -89,8 +101,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(hasAll); - let p2 = launch void>(replaceAll); + let p1 = launch(hasAll) as Job; + let p2 = launch(replaceAll) as Job; p1.Await(); p2.Await(); assertEQ(Atomics.load(flag, 0), 10); @@ -105,8 +117,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(hasAll); - let p2 = launch void>(isEmptyFun); + let p1 = launch(hasAll) as Job; + let p2 = launch(isEmptyFun) as Job; p1.Await(); p2.Await(); assertEQ(Atomics.load(flag, 0), 10); @@ -117,8 +129,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(hasAll); - let p2 = launch void>(clearAll); + let p1 = launch(hasAll) as Job; + let p2 = launch(clearAll) as Job; p1.Await(); p2.Await(); assertTrue(Atomics.load(flag, 0) >= 0); @@ -129,8 +141,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(hasAll); - let p2 = launch void>(removeAllBack); + let p1 = launch(hasAll) as Job; + let p2 = launch(removeAllBack) as Job; p1.Await(); p2.Await(); assertTrue(Atomics.load(flag, 0) >= 0); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_IsEmptyTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_IsEmptyTest.ets index 2288a6c1e1ffd8518098848f8870276b89573ded..b94d759c33bde078db345885ae5d8895e008407e 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_IsEmptyTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_IsEmptyTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; @@ -62,8 +74,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); setAll(); assertFalse(concurrentHashMapOne.isEmpty()); - let p1 = launch void>(isEmptyFun); - let p2 = launch void>(clearAll); + let p1 = launch(isEmptyFun) as Job; + let p2 = launch(clearAll)as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -75,8 +87,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); setAll(); assertFalse(concurrentHashMapOne.isEmpty()); - let p1 = launch void>(isEmptyFun); - let p2 = launch void>(removeAll); + let p1 = launch(isEmptyFun) as Job; + let p2 = launch(removeAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_KeysTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_KeysTest.ets index a77ec8926465281433b11b85f99699a21fd972bb..60c002d0598249bd340db1902ddffe46f128ca37 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_KeysTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_KeysTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; @@ -90,8 +102,8 @@ function main(): int { { concurrentHashMapKeys.clear(); assertTrue(concurrentHashMapKeys.isEmpty()); - let p1 = launch void>(setAll); - let p2 = launch void>(keysAll); + let p1 = launch(setAll) as Job; + let p2 = launch(keysAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapKeys.size >= 0); @@ -101,8 +113,8 @@ function main(): int { concurrentHashMapKeys.clear(); assertTrue(concurrentHashMapKeys.isEmpty()); setAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>(keysAll); + let p1 = launch(deleteAll) as Job; + let p2 = launch(keysAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapKeys.isEmpty()); @@ -112,8 +124,8 @@ function main(): int { concurrentHashMapKeys.clear(); assertTrue(concurrentHashMapKeys.isEmpty()); setAll(); - let p1 = launch void>(clearAll); - let p2 = launch void>(keysAll); + let p1 = launch(clearAll) as Job; + let p2 = launch(keysAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapKeys.isEmpty()); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Delete.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Delete.ets index 76d3a27c83f4ce83134d9179ffd93133b2fafbc1..3b868b07d99f66fc6e23920aab30f1b7cbf86224 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Delete.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Delete.ets @@ -13,8 +13,20 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let pressureFlag: number = 0; @@ -35,7 +47,7 @@ function main(): int { let jobs = new Array>(100); pressureFlag = 0; for (let i: int = 0; i < 100; i++) { - jobs[i] = launch void>(deleteForPressure, pressureFlag); + jobs[i] = launch(deleteForPressure, pressureFlag) as Job; pressureFlag += 1; } for (let i: int = 0; i < 100; i++) { diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Remove.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Remove.ets index 26681fceb33f2cae635e8017107dc386831b3128..12aedb398ede4d90ad03138b44207816cb95481a 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Remove.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Remove.ets @@ -13,8 +13,20 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let pressureFlag: number = 0; @@ -37,7 +49,7 @@ function main(): int { let jobs = new Array>(100); pressureFlag = 0; for (let i: int = 0; i < 100; i++) { - jobs[i] = launch void>(removeForPressure, pressureFlag); + jobs[i] = launch(removeForPressure, pressureFlag) as Job; pressureFlag += 1; } for (let i: int = 0; i < 100; i++) { diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Replace.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Replace.ets index f1b554f9234eba979ba4017b35684ea9a8c1d044..5c8e70c70840786d0fa622f5aa43c0b157b1092c 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Replace.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Replace.ets @@ -13,8 +13,20 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let pressureFlag: number = 0; @@ -35,7 +47,7 @@ function main(): int { let jobs = new Array>(100); pressureFlag = 0; for (let i: int = 0; i < 100; i++) { - jobs[i] = launch void>(replaceForPressure, pressureFlag); + jobs[i] = launch(replaceForPressure, pressureFlag) as Job; pressureFlag += 1; } for (let i: int = 0; i < 100; i++) { diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Set.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Set.ets index 61e94faf2677a8b06dcc5ec6b51f37f77db758a6..094b7c8f0eefce1318fdf4575d177f741e5cf250 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Set.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_PressureTest_Set.ets @@ -13,8 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } let pressureFlag: number = 0; @@ -31,7 +42,7 @@ function main(): int { let jobs = new Array>(100); pressureFlag = 0; for (let i: int = 0; i < 100; i++) { - jobs[i] = launch void>(setForPressure, pressureFlag); + jobs[i] = launch(setForPressure, pressureFlag) as Job; pressureFlag += 1; } for (let i: int = 0; i < 100; i++) { diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_RemoveTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_RemoveTest.ets index 72689a340c67626d051adbdf63e51b292cc49457..d1ea45d8db422902e2347d67b1edf52534a37e25 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_RemoveTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_RemoveTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; let arrValues: string[] = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; @@ -68,8 +80,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(removeAll); - let p2 = launch void>(removeAllBack); + let p1 = launch(removeAll) as Job; + let p2 = launch(removeAllBack) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ReplaceTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ReplaceTest.ets index e024cb41dd00b80208f985232cab93f6c3f4f43d..d0d0d710085493d639553f3f47c438fdb92ce1f4 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ReplaceTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ReplaceTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let buf = new ArrayBuffer(4); let flag: Int8Array = new Int8Array(buf, 0, 4); @@ -78,8 +90,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); setAll(); Atomics.store(flag, 0, 0); - let p1 = launch void>(replaceAll); - let p2 = launch void>(replaceAll); + let p1 = launch(replaceAll) as Job; + let p2 = launch(replaceAll) as Job; p1.Await(); p2.Await(); for (let i = 0; i < 10; i++) { @@ -93,8 +105,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(replaceAll); - let p2 = launch void>(isEmptyFun); + let p1 = launch(replaceAll) as Job; + let p2 = launch(isEmptyFun) as Job; p1.Await(); p2.Await(); assertEQ(Atomics.load(flag, 0), 10); @@ -109,8 +121,8 @@ function main(): int { assertTrue(concurrentHashMapOne.isEmpty()); Atomics.store(flag, 0, 0); setAll(); - let p1 = launch void>(replaceAllBack); - let p2 = launch void>(clearAll); + let p1 = launch(replaceAllBack) as Job; + let p2 = launch(clearAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -122,8 +134,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(replaceAll); - let p2 = launch void>(removeAllBack); + let p1 = launch(replaceAll) as Job; + let p2 = launch(removeAllBack) as Job; p1.Await(); p2.Await(); let flagCounter: int = 0; diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_SetTest_Three.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_SetTest_Three.ets index 68f8a7f012dc2a576216adb9c7265dc91f7767ab..d3899ce476d07cf308da696a9be0366e3c90e71f 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_SetTest_Three.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_SetTest_Three.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; @@ -32,8 +44,8 @@ function main(): int { { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); - let p1 = launch void>(setAll); - let p2 = launch void>(keysAll); + let p1 = launch(setAll) as Job; + let p2 = launch(keysAll) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -42,8 +54,8 @@ function main(): int { { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); - let p1 = launch void>(setAll); - let p2 = launch void>(valuesAll); + let p1 = launch(setAll) as Job; + let p2 = launch(valuesAll) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -52,8 +64,8 @@ function main(): int { { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); - let p1 = launch void>(setAll); - let p2 = launch void>($_iteratorAll); + let p1 = launch(setAll) as Job ; + let p2 = launch($_iteratorAll) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -62,8 +74,8 @@ function main(): int { { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); - let p1 = launch void>(setAll); - let p2 = launch void>(entriesAll); + let p1 = launch(setAll) as Job; + let p2 = launch(entriesAll) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -73,8 +85,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); flag = 0; - let p1 = launch void>(forEachZero); - let p2 = launch void>(setAll); + let p1 = launch(forEachZero) as Job; + let p2 = launch(setAll) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -84,8 +96,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); flag = 0; - let p1 = launch void>(setAll); - let p2 = launch void>(forEachOne); + let p1 = launch(setAll) as Job; + let p2 = launch(forEachOne)as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -95,8 +107,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); flag = 0; - let p1 = launch void>(setAll); - let p2 = launch void>(forEachTwo); + let p1 = launch(setAll)as Job; + let p2 = launch(forEachTwo)as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -106,8 +118,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); flag = 0; - let p1 = launch void>(setAll); - let p2 = launch void>(forEachThree); + let p1 = launch(setAll)as Job; + let p2 = launch(forEachThree)as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_SetTest_Two.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_SetTest_Two.ets index c757c4c81b423b2bce91cf7f7ad1de8600fa145b..e533cefc63a4d9fbb364462f3916d070f80533e8 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_SetTest_Two.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_SetTest_Two.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; @@ -38,8 +50,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setFront(); - let p1 = launch void>(setBack); - let p2 = launch void>(getAll); + let p1 = launch(setBack) as Job; + let p2 = launch(getAll) as Job; p1.Await(); p2.Await(); for (let i: int = 0; i < 10; i++) { @@ -58,8 +70,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setFront(); - let p1 = launch void>(setBack); - let p2 = launch void>(deleteAll); + let p1 = launch(setBack) as Job; + let p2 = launch(deleteAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.size <= 5); @@ -69,8 +81,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setFront(); - let p1 = launch void>(setBack); - let p2 = launch void>(replaceAll); + let p1 = launch(setBack) as Job; + let p2 = launch(replaceAll) as Job; p1.Await(); p2.Await(); flag = 0; @@ -86,8 +98,8 @@ function main(): int { { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); - let p1 = launch void>(setAll); - let p2 = launch void>(isEmptyFun); + let p1 = launch(setAll) as Job; + let p2 = launch(isEmptyFun) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -96,8 +108,8 @@ function main(): int { { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); - let p1 = launch void>(setAll); - let p2 = launch void>(clearAll); + let p1 = launch(setAll) as Job; + let p2 = launch(clearAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.get(9) == undefined || concurrentHashMapOne.get(9) == "nine"); @@ -108,8 +120,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setFront(); - let p1 = launch void>(setBack); - let p2 = launch void>(removeAll); + let p1 = launch(setBack) as Job; + let p2 = launch(removeAll) as Job; p1.Await(); p2.Await(); flag = 0; diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ValuesTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ValuesTest.ets index 9a0b153ea51fbb30963f5b3a4c7222bfe6999e19..66fb41cff896f0101e9e4f34826d2605a83d92e3 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ValuesTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_ValuesTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; @@ -90,8 +102,8 @@ function main(): int { { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); - let p1 = launch void>(setAll); - let p2 = launch void>(valuesAll); + let p1 = launch(setAll) as Job; + let p2 = launch(valuesAll) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -101,8 +113,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>(valuesAll); + let p1 = launch(deleteAll) as Job; + let p2 = launch(valuesAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -112,8 +124,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(clearAll); - let p2 = launch void>(valuesAll); + let p1 = launch(clearAll) as Job; + let p2 = launch(valuesAll)as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_iteratorTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_iteratorTest.ets index 182e39650e106fba8a8c1e702205b0e41659c082..d241ebc8373b49ba811755e0673dd56f0c9f161e 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_iteratorTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_hash_map/ConcurrentHashMap_iteratorTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; @@ -88,8 +100,8 @@ function main(): int { { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); - let p1 = launch void>(setAll); - let p2 = launch void>($_iteratorAll); + let p1 = launch(setAll) as Job; + let p2 = launch($_iteratorAll) as Job; p1.Await(); p2.Await(); assertEQ(concurrentHashMapOne.size, 10); @@ -99,8 +111,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>($_iteratorAll); + let p1 = launch(deleteAll) as Job; + let p2 = launch($_iteratorAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); @@ -110,8 +122,8 @@ function main(): int { concurrentHashMapOne.clear(); assertTrue(concurrentHashMapOne.isEmpty()); setAll(); - let p1 = launch void>(clearAll); - let p2 = launch void>($_iteratorAll); + let p1 = launch(clearAll) as Job; + let p2 = launch($_iteratorAll) as Job; p1.Await(); p2.Await(); assertTrue(concurrentHashMapOne.isEmpty()); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_AddTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_AddTest.ets index 91a8108fef9caa9ac7115a43f20be9e3da51d628..bd66a425f18857c238f40811cad4c30318559b4f 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_AddTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_AddTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; let arrValues: string[] = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; @@ -73,8 +85,8 @@ function main(): int { { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); - let p1 = launch void>(addAll); - let p2 = launch void>(toStringTest); + let p1 = launch(addAll) as Job; + let p2 = launch(toStringTest) as Job; p1.Await(); p2.Await(); let str: string = ConcurrentSetTestOne.toString(); @@ -84,7 +96,7 @@ function main(): int { { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); - let p = launch void>(addAll); + let p = launch(addAll) as Job; p.Await(); assertEQ(ConcurrentSetTestOne.size, 10); }); @@ -92,8 +104,8 @@ function main(): int { { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); - let p1 = launch void>(addAll); - let p2 = launch void>(hasAll); + let p1 = launch(addAll) as Job; + let p2 = launch(hasAll) as Job; p1.Await(); p2.Await(); for (let i: int = 0; i < 10; i++) { @@ -104,8 +116,8 @@ function main(): int { { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); - let p1 = launch void>(addAll); - let p2 = launch void>(getSize); + let p1 = launch(addAll) as Job; + let p2 = launch(getSize) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 10); @@ -115,8 +127,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addFront(); - let p1 = launch void>(addBack); - let p2 = launch void>(deleteAll); + let p1 = launch(addBack) as Job; + let p2 = launch(deleteAll) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 6); @@ -125,8 +137,8 @@ function main(): int { { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); - let p1 = launch void>(addOneTest, 2); - let p2 = launch void>(clearTest); + let p1 = launch(addOneTest, 2) as Job; + let p2 = launch(clearTest) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 2); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_DeleteTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_DeleteTest.ets index 4f776ec24572d9ba699930e834baad27bbdae805..ce3ca679f7ec941e7c149ff0f48557e5a2b87244 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_DeleteTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_DeleteTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; let arrValues: string[] = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; @@ -81,10 +93,10 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p1 = launch void>(deleteOne, 0); - let p2 = launch void>(deleteOne, 1); - let p3 = launch void>(deleteOne, 2); - let p4 = launch void>(getSize); + let p1 = launch(deleteOne, 0) as Job; + let p2 = launch(deleteOne, 1) as Job; + let p3 = launch(deleteOne, 2) as Job; + let p4 = launch(getSize) as Job; p1.Await(); p2.Await(); p3.Await(); @@ -96,9 +108,9 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p1 = launch void>(deleteOne, 0); - let p2 = launch void>(deleteOne, 1); - let p3 = launch void>(hasOne, 3); + let p1 = launch(deleteOne, 0) as Job; + let p2 = launch(deleteOne, 1) as Job; + let p3 = launch(hasOne, 3) as Job; p1.Await(); p2.Await(); p3.Await(); @@ -109,8 +121,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p1 = launch void>(deleteOne, 0); - let p2 = launch void>(clearTest); + let p1 = launch(deleteOne, 0) as Job; + let p2 = launch(clearTest) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.has(0), false); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_EntriesTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_EntriesTest.ets index 2ba56fc978baeeb2c58a72be8b3e93cf09b3a86e..364bdf9b21b972b807075783858e35c0f4e58cac 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_EntriesTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_EntriesTest.ets @@ -12,8 +12,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } -import { launch } from "std/concurrency" let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; let arrValues: string[] = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; @@ -40,8 +51,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addFront(); - let p1 = launch void>(addBack); - let p2 = launch void>(entriesAll); + let p1 = launch(addBack) as Job; + let p2 = launch(entriesAll) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 10); @@ -51,8 +62,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>(entriesAll); + let p1 = launch(deleteAll) as Job; + let p2 = launch(entriesAll) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 10); @@ -62,8 +73,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p1 = launch void>(entriesAll); - let p2 = launch void>(clearTest); + let p1 = launch(entriesAll) as Job; + let p2 = launch(clearTest) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 10); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_One.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_One.ets index a7807d3760f75af02af22f547285416de2a25b2a..2c74b8a93fac8eda81e4fcb265e7966fddfa38ba 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_One.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_One.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; @@ -44,8 +56,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; - let p1 = launch void>(forEachOne); - let p2 = launch void>(addAll); + let p1 = launch(forEachOne) as Job; + let p2 = launch(addAll) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size >= 0); @@ -65,8 +77,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachOne); - let p2 = launch void>(deleteAllBack); + let p1 = launch(forEachOne) as Job; + let p2 = launch(deleteAllBack) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 11); @@ -77,8 +89,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachOne); - let p2 = launch void>(hasAll); + let p1 = launch(forEachOne) as Job; + let p2 = launch(hasAll) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 10); @@ -89,8 +101,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachOne); - let p2 = launch void>(clearTest); + let p1 = launch(forEachOne) as Job; + let p2 = launch(clearTest) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 11); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Three.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Three.ets index bc1582ee649f310f28a56de7f588e2b96f287842..22170dc78811905b9166d0c866795c2280bdfd46 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Three.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Three.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; @@ -49,8 +61,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; - let p1 = launch void>(forEachThree); - let p2 = launch void>(addAll); + let p1 = launch(forEachThree) as Job; + let p2 = launch(addAll) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size >= 0); @@ -61,8 +73,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachThree); - let p2 = launch void>(deleteAllBack); + let p1 = launch(forEachThree) as Job; + let p2 = launch(deleteAllBack) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 11); @@ -73,8 +85,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachThree); - let p2 = launch void>(hasAll); + let p1 = launch(forEachThree) as Job; + let p2 = launch(hasAll) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 10); @@ -85,8 +97,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachThree); - let p2 = launch void>(clearTest); + let p1 = launch(forEachThree) as Job; + let p2 = launch(clearTest) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 11); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Two.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Two.ets index 9d8ebe80959cab881e27829578cfe8d514638bb3..d1e4d435670b45abbcdeea74bddf1df36019239b 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Two.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Two.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; @@ -49,8 +61,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; - let p1 = launch void>(forEachTwo); - let p2 = launch void>(addAll); + let p1 = launch(forEachTwo) as Job; + let p2 = launch(addAll) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size >= 0); @@ -61,8 +73,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachTwo); - let p2 = launch void>(deleteAllBack); + let p1 = launch(forEachTwo) as Job; + let p2 = launch(deleteAllBack) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 11); @@ -73,8 +85,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachTwo); - let p2 = launch void>(hasAll); + let p1 = launch(forEachTwo) as Job; + let p2 = launch(hasAll) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 10); @@ -85,8 +97,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachTwo); - let p2 = launch void>(clearTest); + let p1 = launch(forEachTwo) as Job; + let p2 = launch(clearTest) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 11); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Zero.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Zero.ets index 22e620d284d457693d9f9780dd50b83dbe034233..1076fb4f951b96df9528ed9ff285a965c454429e 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Zero.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ForEachTest_Zero.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; @@ -40,8 +52,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; - let p1 = launch void>(forEachZero); - let p2 = launch void>(addAll); + let p1 = launch(forEachZero) as Job; + let p2 = launch(addAll) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size >= 0); @@ -61,8 +73,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachZero); - let p2 = launch void>(deleteAllBack); + let p1 = launch(forEachZero) as Job; + let p2 = launch(deleteAllBack) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 11); @@ -73,8 +85,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachZero); - let p2 = launch void>(hasAll); + let p1 = launch(forEachZero) as Job; + let p2 = launch(hasAll) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 10); @@ -85,8 +97,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); flag = 0; addAll(); - let p1 = launch void>(forEachZero); - let p2 = launch void>(clearTest); + let p1 = launch(forEachZero) as Job; + let p2 = launch(clearTest) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 11); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_HasTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_HasTest.ets index 0261f6ce4341ce786a732ece46480d813bb3fc9f..6161d6cfddf3e5725890d129c7fc1fa204d79cd3 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_HasTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_HasTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; let arrValues: string[] = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; @@ -98,8 +110,8 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 0); addAll(); assertEQ(ConcurrentSetTestOne.has(3), true); - let p1 = launch void>(hasOne, 0); - let p2 = launch void>(clearTest); + let p1 = launch(hasOne, 0) as Job; + let p2 = launch(clearTest) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.has(0), false); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_KeysTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_KeysTest.ets index 0f1dff41ca3362b8dccd809ccac4af514b72d59e..ebe3a0ed4ffff542889c1610080bbcca59834a8f 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_KeysTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_KeysTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; @@ -58,8 +70,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addFront(); - let p1 = launch void>(addBack); - let p2 = launch void>(keysAll); + let p1 = launch(addBack) as Job; + let p2 = launch(keysAll) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 10); @@ -69,8 +81,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>(keysAll); + let p1 = launch(deleteAll) as Job; + let p2 = launch(keysAll) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 0); @@ -89,8 +101,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p1 = launch void>(keysAll); - let p2 = launch void>(clearTest); + let p1 = launch(keysAll) as Job; + let p2 = launch(clearTest) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 11); @@ -100,7 +112,7 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p = launch void>(keysAll); + let p = launch(keysAll) as Job; clearTest(); p.Await(); assertEQ(ConcurrentSetTestOne.size, 0); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_PressureTest_Delete.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_PressureTest_Delete.ets index d9f53c8792c7f911855cb04262ba50fe92bc50ec..46bd0ef03c34d2d7098ce6be08f3c9718a0fcdf9 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_PressureTest_Delete.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_PressureTest_Delete.ets @@ -13,9 +13,23 @@ * limitations under the License. */ -import { launch } from "std/concurrency" + import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + + let ConcurrentSetTestOne: ConcurrentSet = new ConcurrentSet(); function main(): int { @@ -31,7 +45,7 @@ function main(): int { assertEQ(ConcurrentSetTestOne.size, 100); let jobs = new Array>(100); for (let i: int = 0; i < 100; i++) { - jobs[i] = launch void>(deleteMore, i); + jobs[i] = launch(deleteMore, i) as Job; } for (let i: int = 0; i < 100; i++) { jobs[i].Await(); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_PressureTest_Set.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_PressureTest_Set.ets index ae60d1f2844b7f0982ac238c98d771acc14e2d65..3d473acf62c7b2d899b8d8b1204a44296acd794f 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_PressureTest_Set.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_PressureTest_Set.ets @@ -13,9 +13,22 @@ * limitations under the License. */ -import { launch } from "std/concurrency" + import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let ConcurrentSetTestOne: ConcurrentSet = new ConcurrentSet(); function main(): int { @@ -28,7 +41,7 @@ function main(): int { let jobs = new Array>(100); for (let i: int = 0; i < 100; i++) { - jobs[i] = launch void>(addMore, i); + jobs[i] = launch(addMore, i) as Job; } for (let i: int = 0; i < 100; i++) { jobs[i].Await(); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ValuesTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ValuesTest.ets index 26c2ff314d3fb885a10ce1bf4223fb684d1b9bfb..580dbd2ec7006c90aa1cecfcd714a8141ba753b8 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ValuesTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_ValuesTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; @@ -78,8 +90,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addFront(); - let p1 = launch void>(addBack); - let p2 = launch void>(valuesAll); + let p1 = launch(addBack) as Job; + let p2 = launch(valuesAll) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 10); @@ -89,8 +101,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>(valuesAll); + let p1 = launch(deleteAll) as Job; + let p2 = launch(valuesAll) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 0); @@ -109,8 +121,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p1 = launch void>(valuesAll); - let p2 = launch void>(clearTest); + let p1 = launch(valuesAll) as Job; + let p2 = launch(clearTest) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 11); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_iteratorTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_iteratorTest.ets index e7774e5a2e06fde44710eec27b54f420cbd9b2f7..d22978326cf85324896e2df60699652e49cad98c 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_iteratorTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/concurrent_set/ConcurrentSet_iteratorTest.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let flag: int = 0; let arrKeys: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; @@ -58,8 +70,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addFront(); - let p1 = launch void>(addBack); - let p2 = launch void>($_iteratorAll); + let p1 = launch(addBack) as Job; + let p2 = launch($_iteratorAll) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 10); @@ -69,8 +81,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p1 = launch void>(deleteAll); - let p2 = launch void>($_iteratorAll); + let p1 = launch(deleteAll) as Job; + let p2 = launch($_iteratorAll) as Job; p1.Await(); p2.Await(); assertEQ(ConcurrentSetTestOne.size, 0); @@ -89,8 +101,8 @@ function main(): int { ConcurrentSetTestOne.clear(); assertEQ(ConcurrentSetTestOne.size, 0); addAll(); - let p1 = launch void>($_iteratorAll); - let p2 = launch void>(clearTest); + let p1 = launch($_iteratorAll) as Job; + let p2 = launch (clearTest) as Job; p1.Await(); p2.Await(); assertTrue(ConcurrentSetTestOne.size < 11); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_AddTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_AddTest.ets index 2dbf2059201ee90f7daa26b70e853f3b4178c88d..dafe25b89a672528bbc500b83c2dc7dbf2515faa 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_AddTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_AddTest.ets @@ -13,8 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } const elementsNum: int = 10; const testNum: int = 20; @@ -53,7 +64,7 @@ function main(): int { } let jobs = new Array>(5); for (let i = 0; i < 5; i++) { - jobs[i] = launch void>(queueAddData); + jobs[i] = launch(queueAddData) as Job; } for (let i: int = 0; i < 5; i++) { jobs[i].Await(); @@ -68,8 +79,8 @@ function main(): int { let jobs = new Array>(6); let p = 0; for (let i = 0; i < 3; i++) { - jobs[p++] = launch void>(queueAddData); - jobs[p++] = launch void>(queuePopData); + jobs[p++] = launch(queueAddData) as Job; + jobs[p++] = launch(queuePopData) as Job; } for (let i: int = 0; i < 6; i++) { jobs[i].Await(); @@ -84,10 +95,10 @@ function main(): int { let jobs = new Array>(10); let p = 0; for (let i = 0; i < 5; i++) { - jobs[p++] = launch void>(queueAddData); + jobs[p++] = launch(queueAddData) as Job; } for (let i = 5; i < 10; i++) { - jobs[p++] = launch void>(queueGetFirstData); + jobs[p++] = launch(queueGetFirstData) as Job; } for (let i: int = 0; i < 10; i++) { jobs[i].Await(); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_AddTest_Stress.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_AddTest_Stress.ets index e581e530534aec9f59d138189450ed6346303d38..48c8103f9cc9715be71f24838c1b6b61c6e92b23 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_AddTest_Stress.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_AddTest_Stress.ets @@ -13,8 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } const stressNum: int = 100; @@ -31,7 +42,7 @@ function main(): int { let jobs = new Array>(100); let p = 0; for (let i = 0; i < 100; i++) { - jobs[p++] = launch void>(sQueueAddData, i); + jobs[p++] = launch(sQueueAddData, i) as Job; } for (let i: int = 0; i < 100; i++) { jobs[i].Await(); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PollTest_Stress.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PollTest_Stress.ets index 581b25caf7632d62c674b7aebe8e1529c7d9be24..de9f84b69d5336fbc270139d168baae0e038e88c 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PollTest_Stress.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PollTest_Stress.ets @@ -13,8 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } const stressNum: int = 100; @@ -34,7 +45,7 @@ function main(): int { let jobs = new Array>(100); let p = 0; for (let i = 0; i < stressNum; i++) { - jobs[p++] = launch void>(sQueuePollData); + jobs[p++] = launch(sQueuePollData) as Job; } for (let i: int = 0; i < 100; i++) { jobs[i].Await(); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PopTest_Stress.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PopTest_Stress.ets index 7b0984f9f1461f2120e1d21cc5f5a3057ebe0ac5..831d5fac89ff6e36df2b7f308b912742fd2eb04f 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PopTest_Stress.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PopTest_Stress.ets @@ -13,8 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } const stressNum: int = 100; @@ -33,7 +44,7 @@ function main(): int { } let jobs = new Array>(100); for (let i = 0; i < stressNum; i++) { - jobs[i] = launch void>(sQueuePopData); + jobs[i] = launch(sQueuePopData) as Job; } for (let i: int = 0; i < 100; i++) { jobs[i].Await(); diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PushTest_Stress.ets b/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PushTest_Stress.ets index 6c21c9c2ed362736be388e85c02ce3a648f4d4c2..5cec18994a53ac7fd0404093f8a5e38e99c27984 100755 --- a/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PushTest_Stress.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/containers/linked_blocking_queue/LinkedBlockingQueue_PushTest_Stress.ets @@ -13,8 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } const testNum: int = 20; const stressNum: int = 100; @@ -32,7 +43,7 @@ function main(): int { let jobs = new Array>(100); let p = 0; for (let i = 0; i < stressNum; i++) { - jobs[p++] = launch void>(sQueuePushData); + jobs[p++] = launch(sQueuePushData) as Job; } for (let i: int = 0; i < 100; i++) { jobs[i].Await(); diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/affinity.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/affinity.ets index 5f5515930c247e55ad87ce89e42034a780e7b6eb..6b6451f0eee5594d73fb102abdfc415c0dddff83 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/affinity.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/affinity.ets @@ -15,7 +15,6 @@ import {CoroutineExtras, AtomicFlag} from "std/debug/concurrency" import {StdDebug} from "std/debug" -import { launch } from "std/concurrency" import { Job } from "std/core" type L = StdDebug.Logger @@ -47,9 +46,22 @@ function checker(id_main: int): Int { function check_sync_id_nonmain(number_of_coros: int): int { let id_current: int = CoroutineExtras.getWorkerId(); let promises: (Job | undefined)[] = new (Job | undefined)[number_of_coros]; + + let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p); + } + } + } for (let i = 0; i < number_of_coros; ++i) { - promises[i] = launch Int>(checker, id_current); + promises[i] = launch(checker, id_current) as Job; } continue_execution.set(true); let result: int = 0; diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/allhandled_rejection.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/allhandled_rejection.ets index 929a94394cc1f5f4e1cdbab4b5a718d5875234a8..1e7d1846b5ea300ab5be0a70d42f2771dccec8ce 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/allhandled_rejection.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/allhandled_rejection.ets @@ -13,6 +13,19 @@ * limitations under the License. */ +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + async function AsyncFailing(): Promise { throw Error("AsyncFailing"); } @@ -43,10 +56,10 @@ function main(): void { }); }); - let g = launch string>(Failing); + let g = launch(Failing) as Job ; try { - launch string>(Failing).Await(); + (launch(Failing) as Job).Await(); } catch(e) { } @@ -73,5 +86,5 @@ function main(): void { } catch (e) { } - launch null>(SingleRejectedJob); + launch(SingleRejectedJob); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/await.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/await.ets index aabf319d74a8bde89c8b6d79dabc248c0525a6d7..1bd3d7cbcbc94abda10d17f727d4a2ed48a76a17 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/await.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/await.ets @@ -13,8 +13,7 @@ * limitations under the License. */ -import {launch} from "std/concurrency"; -import {Job} from "std/core"; +import { Job } from "std/core"; let flag = false @@ -24,7 +23,19 @@ function set_flag(): String { } export function main(): int { - let p = launch String>(set_flag); + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } + } + let p = launch(set_flag) as Job; let result = p.Await(); if (!flag) { diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/await_migrate.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/await_migrate.ets index a4dd81da408f9d58e600f09e16a973e0f8869fa7..88ac24fa59f48eba804aea990692bfc2eaaea164 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/await_migrate.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/await_migrate.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" let isLaunchMigrated: AtomicFlag = new AtomicFlag(false); @@ -46,7 +45,19 @@ function testLaunch(): void { } function checkLaunchMigration(): void { - launch void>(testLaunch).Await(); + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } + } + (launch(testLaunch) as Job).Await(); } function main() { diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/class_load_race.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/class_load_race.ets index 69cd7053870658a67fe8d2d44dcabfc3acf31b0b..17cb9b14cb75bc845f330f06489241f1a899b4d6 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/class_load_race.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/class_load_race.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { launch } from "std/concurrency" class Racer { static x: int = Racer.f(); @@ -41,8 +40,20 @@ function reader(): Int { } function raceInTheCCtor(): void { + let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p); + } + } + } for (let i = 0; i < 20; i++) { - launch Int>(reader); + launch(reader); } } diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/concurrent_await.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/concurrent_await.ets index 57f07e5b5474fe318c80bca02b8a6e0bddbc3a7a..167a3d0a5b777a5f305233371b4b57971fbc756d 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/concurrent_await.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/concurrent_await.ets @@ -15,7 +15,6 @@ import {AtomicFlag} from "std/debug/concurrency" -import { launch } from "std/concurrency" import { Job } from "std/core" class Event { @@ -44,9 +43,22 @@ function bar(p: Job) : int { } function main() { - let p1 = launch int>(foo); + let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p); + } + } + } + + let p1 = launch(foo) as Job ; for (let i = 0; i < 2; ++i) { - let p2 = launch) => int>(bar, p1); + let p2 = launch(bar, p1); } // NOTE(panferovi): for more determinism we need to make sure // that bar coroutines are waiting for its awakening diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/eaworker_coroutines.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/eaworker_coroutines.ets index 7010e6b0daa04943acd986771635aeb09ec5be46..744acfbdaf6289aa41f9dfffc78df4e0dde32507 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/eaworker_coroutines.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/eaworker_coroutines.ets @@ -18,6 +18,22 @@ const EXPECTED_VALUE = 42; let counter = 0; + +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + + + function clearCounter() { counter = 0; } @@ -48,7 +64,7 @@ async function throwAsyncError(): Promise { } function testFooLaunch(): number { - let job : Job = launchnumber>(foo); + let job : Job = launch(foo) as Job; let result = job.Await(); return result; @@ -56,19 +72,19 @@ function testFooLaunch(): number { function testAddSchedule(): void { clearCounter(); - let job: Job = launchvoid>(add, INCREMENT); + let job: Job = launch(add, INCREMENT) as Job; Coroutine.Schedule(); } function recursiveFoo(): Job { - let job: Job = launchnumber>(testFooLaunch); + let job: Job = launch(testFooLaunch) as Job; return job; } function testRecursiveLaunch(): number { - let job: Job> = launch, ()=>Job>(recursiveFoo); + let job: Job> = launch(recursiveFoo) as Job>; let result = job.Await().Await(); return result; @@ -76,7 +92,7 @@ function testRecursiveLaunch(): number { function testLaunchThrow(): boolean { try { - let job: Job = launchvoid>(throwLaunchError); + let job: Job = launch(throwLaunchError) as Job; job.Await(); } catch (e) { return e instanceof Error; @@ -170,7 +186,7 @@ function testACAJcoroutine(): void { function testACoroutineCallAJCoroutine(): void { let ew = new EAWorker(); let job1 = ew.run(() => { - let job2: Job> = launch, ()=>Promise>(fooAsync) + let job2: Job> = launch(fooAsync) as Job> let p = job2.Await(); let result = await p; @@ -183,7 +199,7 @@ function testACoroutineCallAJCoroutine(): void { } async function AsyncCallLaunch(): Promise> { - let job: Job = launchnumber>(foo); + let job: Job = launch(foo) as Job; return job; } diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/execution_order.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/execution_order.ets index 1ff9739213034f001fb8ef5a0eae4ba9adc56d94..385ed9dd995800c911da418e601a8b3d67c57856 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/execution_order.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/execution_order.ets @@ -12,6 +12,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + }; class StepSequence { constructor(numCheckpoints: int) { @@ -48,7 +61,7 @@ async function foo() { async function bar() { executionOrder.checkpoint(2); let emptyBody = () => { return 0; }; - promiseIsPending ? launch Int>(emptyBody).Await() + promiseIsPending ? (launch(emptyBody) as Job).Await() : await Promise.resolve(0); executionOrder.checkpoint(5); } diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch.ets index 658a7cdde77c7c637eb8ae20340bb3d5c547c01c..ffb318bfffed4344e8ab587d922cd08330ece836 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch.ets @@ -13,6 +13,21 @@ * limitations under the License. */ + +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } +} + + class MyPayload { public s: string; constructor(a: number) { @@ -51,47 +66,38 @@ class C { } function main(): void { - const l0Result = launch string>(l0).Await(); - const l1Result = launch string>(l1, "l1_arg_0").Await(); + const l0Result = (launch(l0) as Job).Await(); + const l1Result = ( launch(l1, "l1_arg_0") as Job).Await(); - const l2ResultJob: Job = launch< - string, - (a0: string, a1: number, a2: MyPayload) => string - >(l2, "l2_arg_0", 2.73, new MyPayload(3.14)); + const l2ResultJob: Job = launch(l2, "l2_arg_0", 2.73, new MyPayload(3.14)) as Job; const l2Result = l2ResultJob.Await(); assertEQ(l0Result, "l0"); assertEQ(l1Result, "l1: l1_arg_0"); assertEQ(l2Result, "l2: l2_arg_0 2.73 MyPayload.s=3.14"); - const f0ResultJob: Job = launch string>( + const f0ResultJob: Job = launch( f0 - ); + ) as Job; const f0Result = f0ResultJob.Await(); - const f1ResultJob: Job = launch string>( + const f1ResultJob: Job = launch( f1, "f1_arg_0" - ); + ) as Job; const f1Result = f1ResultJob.Await(); - const f2ResultJob: Job = launch< - string, - (a0: string, a1: number, a2: MyPayload) => string - >(f2, "f2_arg_0", 2.73, new MyPayload(3.14)); + const f2ResultJob: Job = launch(f2, "f2_arg_0", 2.73, new MyPayload(3.14)) as Job; const f2Result = f2ResultJob.Await(); assertEQ(f0Result, "f0"); assertEQ(f1Result, "f1: f1_arg_0"); assertEQ(f2Result, "f2: f2_arg_0 2.73 MyPayload.s=3.14"); - const s0Result = launch string>(C.s0).Await(); - const s1Result = launch string>(C.s1, "C.s1_arg_0" ).Await(); + const s0Result = (launch(C.s0) as Job).Await(); + const s1Result = (launch(C.s1, "C.s1_arg_0" ) as Job).Await(); - const s2ResultJob = launch< - string, - (a0: string, a1: number, a2: MyPayload) => string - >(C.s2, "C.s2_arg_0", 2.73, new MyPayload(3.14)); + const s2ResultJob = launch(C.s2, "C.s2_arg_0", 2.73, new MyPayload(3.14)) as Job; const s2Result = s2ResultJob.Await(); assertEQ(s0Result, "s0"); diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_exception.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_exception.ets index 6a6f30cfe54cc43219e76ab3262d16681cd0592b..4852a20ec0246c92084dd2eba8fd1ecf1474e9da 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_exception.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_exception.ets @@ -13,13 +13,23 @@ * limitations under the License. */ -import { launch } from "std/concurrency" - let counter = 0; function stack_eater(): void { stack_eater(); } +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } + } function coro_stack_overflow(): Object | null { stack_eater(); @@ -32,7 +42,7 @@ function coro_error(): Object { function test_stack_overflow(): boolean { try { - launch Object | null>(coro_stack_overflow).Await(); + (launch(coro_stack_overflow) as Job) .Await(); console.println("No exceptions thrown by coro_stack_overflow() but should be!") return false; } catch (e) { @@ -45,8 +55,9 @@ function test_stack_overflow(): boolean { } function test_error(): boolean { + try { - launch Object>(coro_error).Await(); + (launch(coro_error) as Job).Await(); console.println("No exceptions thrown by coro_error() but should be!") return false; } catch (e) { diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_instr_array.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_instr_array.ets index 28544a77cf602d34afbc4ae47051783017dd667e..b4bfc9ddc285848f9ef1db7d8e2a45b722ab8f75 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_instr_array.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_instr_array.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" // This test covers case of storing Promises returned from launch instruction @@ -24,8 +23,20 @@ class TestCoroutine { public static jArray: (Job | null)[] = [null, null]; public jCor(): Job { + let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p); + } + } + }; const factory = () => {return new Object();} - return launch Object>(factory); + return launch(factory) as Job; } public run(): void { diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_instruction.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_instruction.ets index 50335f605f51b9e8571bd7b3ab16fc0002b955dd..4473305f164396f4f6a68df632abee47b31cee8c 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_instruction.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_instruction.ets @@ -13,10 +13,10 @@ * limitations under the License. */ -import { launch } from "std/concurrency" let passed = false; + function reset() { passed = false; } @@ -120,32 +120,44 @@ function fiveargs(x1: int, x2: int, x3: int, x4: int, x5: int): Object | null { export function main(): int { reset() - launch Object | null>(noarg); + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } + }; + launch(noarg); Coroutine.Schedule(); check("noarg"); reset() - launch Object | null>(onearg, 1); + launch(onearg, 1); Coroutine.Schedule(); check("onearg"); reset() - launch Object | null>(twoargs, 1, 2); + launch(twoargs, 1, 2); Coroutine.Schedule(); check("twoargs"); reset() - launch Object | null>(threeargs, 1, 2, 3); + launch(threeargs, 1, 2, 3); Coroutine.Schedule(); check("threeargs"); reset() - launch Object | null>(fourargs, 1, 2, 3, 4); + launch(fourargs, 1, 2, 3, 4); Coroutine.Schedule(); check("fourargs"); reset() - launch Object | null>(fiveargs, 1, 2, 3, 4, 5); + launch(fiveargs, 1, 2, 3, 4, 5); Coroutine.Schedule(); check("fiveargs"); return 0; diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_n_workers.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_n_workers.ets index adfcfc4c223e26597546989a33328fd11d961408..cfbac4821036c1f5f9767caf806188125c6ec4d7 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_n_workers.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_n_workers.ets @@ -14,9 +14,22 @@ */ -import {StdDebug} from "std/debug" -import {CoroutineExtras} from "std/debug/concurrency" -import { launch } from "std/concurrency" +import { StdDebug } from "std/debug" +import { CoroutineExtras } from "std/debug/concurrency" + +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } +}; + type L = StdDebug.Logger async function async_chain_element(caller_wid: int, counter: int): Promise { @@ -55,7 +68,7 @@ function compare_worker_ids(): int { L.log("Testing launch in a separate worker"); let id_main: int = CoroutineExtras.getWorkerId(); - let id_coro: int = (launch Int>(return_worker_id).Await()) as int; + let id_coro: int = ((launch(return_worker_id) as Job).Await()) as int; if (id_main != id_coro) { L.log("Successfully ran coro in a separate worker. Main WID: " + id_main + ", Coro WID: " + id_coro); return 0; @@ -76,21 +89,21 @@ function job(n: int): NullableType { function run_batch_launch(batch_size: int, iters: int): int { L.log("Testing batch launch of " + batch_size + " coroutines"); for (let i = 0; i < batch_size; ++i) { - launch NullableType>(job, iters); + launch(job, iters); } return 0; } function await_chain(n: int): NullableType { if (n > 0) { - launch NullableType>(await_chain, n-1).Await(); + (launch(await_chain, n - 1) as Job).Await(); } return null; } function run_await_chain(len: int): int { L.log("Testing await chain of " + len + " items"); - launch NullableType>(await_chain, len); + launch(await_chain, len); return 0; } @@ -101,7 +114,7 @@ function simple(): NullableType { function run_batch_await(batch_size: int): int { L.log("Testing batch await of " + batch_size + " coroutines"); for (let i = 0; i < batch_size; ++i) { - let j = launch NullableType>(simple); + let j = launch(simple) as Job; j.Await(); } return 0; diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_oom.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_oom.ets index 0539f5729e9285a860f09fed6dcff1420857d790..bb7920f5c4cdd9f90ea7b762d5984cd9044e6f39 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_oom.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_oom.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { launch } from "std/concurrency" let counter = 0; @@ -22,9 +21,21 @@ function body(): Object { } export function main(): int { + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } + }; try { for (let i = 0; i < 50000; ++i) { - launch Object>(body); + launch(body); ++counter; } } catch (e) { diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_yield.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_yield.ets index 25b3e9348b9ebae216a4d6e68220d318b055ed87..68764634e01f0d22b24951e47d13fe91168bf712 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_yield.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/launch_yield.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { launch } from "std/concurrency" let counter = 0; @@ -23,7 +22,19 @@ function add(a: int): String { } export function main(): int { - launch String>(add, 5); + let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p); + } + } + }; + launch(add, 5); Coroutine.Schedule(); if (counter != 5) { console.println("Invalid counter: expected 5 but was " + counter); diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/multiple_launch.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/multiple_launch.ets index 2a3c338608702f20a66e6550f0d0a3b2741c82c1..414ba9843a9b9685fdd17279da7700c365de9014 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/multiple_launch.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/multiple_launch.ets @@ -13,17 +13,29 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" function return_value(i: int): String { return "value " + i; } +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p); + } + } + }; + function n_cor_launch(n_cor: int): int { let p: (Job | undefined)[] = new (Job | undefined)[n_cor]; for (let i = 0; i < n_cor; ++i) { - p[i] = launch String>(return_value, i); + p[i] = launch(return_value, i) as Job ; } for (let i = 0; i < n_cor; ++i) { let val = (p[i]!).Await(); @@ -42,7 +54,7 @@ function throw_exception(): Object { function n_cor_exection_launch(n_cor: int): int { let p: (Job | undefined)[] = new (Job | undefined)[n_cor]; for (let i = 0; i < n_cor; ++i) { - p[i] = launch Object>(throw_exception); + p[i] = launch(throw_exception) as Job; } for (let i = 0; i < n_cor; ++i) { try { diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/scale_workers_pool.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/scale_workers_pool.ets index 93f6e4569028f551521a390ba9c146f4f09373dd..d9374e520dec21a4e911d303787590eaddc19acc 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/scale_workers_pool.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/scale_workers_pool.ets @@ -14,15 +14,27 @@ */ function main() { + let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p); + } + } + }; let mainId = CoroutineExtras.getWorkerId(); CoroutineExtras.scaleWorkersPool(1); CoroutineExtras.setSchedulingPolicy(CoroutineExtras.POLICY_NON_MAIN); - let workerId = launch Int>((): Int => { return CoroutineExtras.getWorkerId(); }).Await(); + let workerId = (launch((): Int => { return CoroutineExtras.getWorkerId(); }) as Job).Await(); CoroutineExtras.scaleWorkersPool(-1); assertNE(mainId, workerId); CoroutineExtras.setSchedulingPolicy(CoroutineExtras.POLICY_ANY); - workerId = launch Int>((): Int => { return CoroutineExtras.getWorkerId(); }).Await(); + workerId = (launch((): Int => { return CoroutineExtras.getWorkerId(); }) as Job).Await(); assertEQ(mainId, workerId); } diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/setTimeout.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/setTimeout.ets index efadaecc0f11ceacdc9846b92d4d82246f6b661b..c1aa638e8a78936f3aec3b6c3aad023ab2f3c7d9 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/setTimeout.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/setTimeout.ets @@ -13,9 +13,20 @@ * limitations under the License. */ -import { launch } from "std/concurrency" type Test = () => void; +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p); + } + } + }; let tests = new Array( setTimeoutTest, @@ -75,7 +86,7 @@ function clearIntervalFromAnotherTimer() { function clearTimeoutFromAnotherWorkerTest() { let id = setTimeout(() => { assertTrue(false); }, longTimeout); - launch void>(clearTimeout, id); + launch(clearTimeout, id); } function sameWorkerIdTest() { @@ -86,6 +97,6 @@ function sameWorkerIdTest() { function main() { CoroutineExtras.setSchedulingPolicy(CoroutineExtras.POLICY_NON_MAIN); for (let test of tests) { - launch void>(test); + launch(test); } } diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/stats.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/stats.ets index ddc5f3611aa151eefd751dc5e55e6696d8877693..cf56714ad972806a5d22bcf44cd9620cf1c6c2ec 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/stats.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/stats.ets @@ -13,10 +13,10 @@ * limitations under the License. */ -import { launch } from "std/concurrency" // This test checks if the coroutine statistics engine works correctly. + function sync_f(a: int): String { return "Some dummy string:" + a } @@ -26,11 +26,24 @@ async function async_f(a: int): Promise { } export function main(): int { + let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p); + } + } + }; + for (let i = 0; i < 10; ++i) { - launch String>(sync_f, 5); + launch(sync_f, 5); } for (let i = 0; i < 10; ++i) { - launch String>(sync_f, 5).Await(); + (launch(sync_f, 5) as Job).Await(); } for (let i = 0; i < 10; ++i) { async_f(5); diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/unhandled_rejection.ets b/static_core/plugins/ets/tests/ets_test_suite/coroutines/unhandled_rejection.ets index eda2d4cd21c6ea34c3074c2ac229087962cbea78..a07c1795dee9bc5293204ce1b36daf95a49bae0e 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/unhandled_rejection.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/unhandled_rejection.ets @@ -14,6 +14,18 @@ */ import {AtomicFlag} from "std/debug/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } class Event { constructor() { @@ -54,7 +66,7 @@ function WaitAll(): null { function Handler(obj: Object): void { if (current == 0) { - launch null>(WaitAll); + launch(WaitAll); } current++; if (current == kTotal) { @@ -75,8 +87,8 @@ function main(): void { StdProcess.process.on("unhandledJobRejection", Handler); StdProcess.process.on("unhandledPromiseRejection", Handler); - let g = launch string>(Failing); - launch, () => Promise>(AsyncFailing); + let g = launch(Failing) as Job; + launch(AsyncFailing); AsyncFailing(); let p = Promise.reject(new Error("promise1")); let q = p.then(() => { diff --git a/static_core/plugins/ets/tests/ets_test_suite/gc/finalization_registry_coro_test.ets b/static_core/plugins/ets/tests/ets_test_suite/gc/finalization_registry_coro_test.ets index ecb36587cb82a9d016b32a5ba41631a180d01115..e2b17841a5df488df1d48ff9cd3d38874c160459 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/gc/finalization_registry_coro_test.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/gc/finalization_registry_coro_test.ets @@ -13,9 +13,21 @@ * limitations under the License. */ +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + const object_count = 20; const promise_count = 30; - let token = new Object(); let registry: FinalizationRegistry | null = null; @@ -57,7 +69,7 @@ let promise_array: Array> = new Array>; function getSizeTests(finreg: FinalizationRegistry | null) { for (let i = 0; i < promise_count; i++) { - promise_array.push(launch | null, b: Int, c: Object) => void>(addToRegistry, finreg, 3, token)); + promise_array.push(launch(addToRegistry, finreg, 3, token) as Job); } for (let i = 0; i < promise_array.length; i++) { @@ -92,10 +104,10 @@ function unregisterTests(finreg: FinalizationRegistry | null) { return finreg.unregister(s); }; - launch, token: Object) => void>(unregister, finreg!, token1).Await(); - launch, token: Object) => void>(unregister, finreg!, token2).Await(); - launch, token: Object) => void>(unregister, finreg!, token3).Await(); - launch, token: Object) => void>(unregister, finreg!, token4).Await(); + (launch(unregister, finreg!, token1) as Job).Await(); + (launch(unregister, finreg!, token2) as Job).Await(); + (launch(unregister, finreg!, token3) as Job).Await(); + (launch(unregister, finreg!, token4) as Job).Await(); assertEQ(0, finreg!.getSize(), "Size of unregister is invalid"); @@ -106,7 +118,7 @@ function unregisterTests(finreg: FinalizationRegistry | null) { assertEQ(obj_array.length * object_count, finreg!.getSize(), "Register function is invalid"); for (let i = 0; i < obj_array.length; i++) { - unreg_array.push(launch | null, b: Object) => void>(removeFromRegistry, finreg!, obj_array[i])); + unreg_array.push(launch(removeFromRegistry, finreg!, obj_array[i]) as Job); } for (let i = 0; i < unreg_array.length; ++i) { diff --git a/static_core/plugins/ets/tests/ets_test_suite/gc/stress/test_stress_gc_humongous.ets b/static_core/plugins/ets/tests/ets_test_suite/gc/stress/test_stress_gc_humongous.ets index 7ada0aaebfd85a34df417ba55cbbf8f105005975..ba8999a4d96d16c20524078b1d64fdbff216afbe 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/gc/stress/test_stress_gc_humongous.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/gc/stress/test_stress_gc_humongous.ets @@ -13,8 +13,20 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + // This test tries to load gc with a large number of memory allocations // close to the OOM situation @@ -78,9 +90,9 @@ class TestHumongousStress { let corArrayTmp = new Array>(); for(let i = 0; i < this.threadsCount - 1; i++) { - corArrayTmp.push(launch Object|null>(cor, objPerCoroutine, this.humongousSize)); + corArrayTmp.push(launch(cor, objPerCoroutine, this.humongousSize) as Job); } - let corArrayLast = launch Object|null>(cor, lastCoroutuneNumObjects, this.humongousSize); + let corArrayLast = launch(cor, lastCoroutuneNumObjects, this.humongousSize) as Job; Coroutine.Schedule(); diff --git a/static_core/plugins/ets/tests/ets_test_suite/gc/stress/test_stress_gc_humongous_bq.ets b/static_core/plugins/ets/tests/ets_test_suite/gc/stress/test_stress_gc_humongous_bq.ets index a63b02db5f8f7947144f58c4621c345798d8ad75..83ce77e4f885b57b76c24c2de34c01ded16b6541 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/gc/stress/test_stress_gc_humongous_bq.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/gc/stress/test_stress_gc_humongous_bq.ets @@ -13,8 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } // This test tries to load gc with a large number of memory allocations // close to the OOM situation @@ -83,9 +94,9 @@ class TestHumongousStress { let corArrayTmp = new Array>(); for(let i = 0; i < this.threadsCount - 1; i++) { - corArrayTmp.push(launch Object|null>(TestHumongousStress.cor, objPerCoroutine, this.humongousSize)); + corArrayTmp.push(launch(TestHumongousStress.cor, objPerCoroutine, this.humongousSize) as Job); } - let corArrayLast = launch Object|null>(TestHumongousStress.cor, lastCoroutuneNumObjects, this.humongousSize); + let corArrayLast = launch(TestHumongousStress.cor, lastCoroutuneNumObjects, this.humongousSize) as Job; Coroutine.Schedule(); diff --git a/static_core/plugins/ets/tests/ets_test_suite/gc/test_finreg_in_different_coros.ets b/static_core/plugins/ets/tests/ets_test_suite/gc/test_finreg_in_different_coros.ets index fa0a2f78e5fb356134c4e19e8b83467a450dca08..802ec56935d2baeafa42b128fbae2ac9a6f869f0 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/gc/test_finreg_in_different_coros.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/gc/test_finreg_in_different_coros.ets @@ -13,7 +13,19 @@ * limitations under the License. */ -import { launch } from "std/concurrency" +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + let registry: FinalizationRegistry | null = null; let registry2: FinalizationRegistry | null = null; @@ -51,7 +63,7 @@ function InitFinRegAndFill(callback: (value: int) => void, isMainCoro: boolean = function runGCInDiffThreads() { doFullGC(); CoroutineExtras.setSchedulingPolicy(CoroutineExtras.POLICY_NON_MAIN); - launch void>(doFullGC).Await(); + (launch(doFullGC) as Job).Await(); CoroutineExtras.setSchedulingPolicy(CoroutineExtras.POLICY_ANY); } @@ -62,7 +74,7 @@ function testFinRegOnMainAndDiffCoro() { result_finreg_not_main = value; } CoroutineExtras.setSchedulingPolicy(CoroutineExtras.POLICY_NON_MAIN); - launch void, f: boolean) => void>(InitFinRegAndFill, cb, false).Await(); + (launch(InitFinRegAndFill, cb, false) as Job).Await(); CoroutineExtras.setSchedulingPolicy(CoroutineExtras.POLICY_ANY); InitFinRegAndFill((value: int) => { result_finreg_main = value; diff --git a/static_core/plugins/ets/tests/ets_test_suite/linker/runtime_linker_extensions.ets b/static_core/plugins/ets/tests/ets_test_suite/linker/runtime_linker_extensions.ets index f0218a21548fcb80b5e4e351b38e1bd0ecfc4f09..412c23cd24eaef6423ee76f1784d6fdea1ca232f 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/linker/runtime_linker_extensions.ets +++ b/static_core/plugins/ets/tests/ets_test_suite/linker/runtime_linker_extensions.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { launch } from "std/concurrency" + import { Job } from "std/core" class A { } @@ -250,9 +250,22 @@ class Test { const linker = new AbcRuntimeLinker(undefined, []); const allAbcFiles = Test.getAdditionalFilesList(); const promises = new Array>(); + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + } // Add all files except "additional1.ets" for (let i = 1; i < allAbcFiles.length; i++) { - promises.push(launch void>(Test.addSingleAbcFile, linker, allAbcFiles[i])); + promises.push(launch(Test.addSingleAbcFile, linker, allAbcFiles[i]) as Job); } // Try to load a class from "additional1.ets" expectThrow(() => { linker.loadClass(Test.additionalClass1Name, true); }, diff --git a/static_core/plugins/ets/tests/interop_js/tests/coroutines/ts_to_ets/ets_coroutines_interop.ets b/static_core/plugins/ets/tests/interop_js/tests/coroutines/ts_to_ets/ets_coroutines_interop.ets index f1d5c5de19b9096320ef52a6f9ff74cb4420f53a..5c784e110d6491a6b428684ebe0142c0712525d0 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/coroutines/ts_to_ets/ets_coroutines_interop.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/coroutines/ts_to_ets/ets_coroutines_interop.ets @@ -18,9 +18,20 @@ import { createFooClassFromTs, } from 'main_js'; -import { launch } from "std/concurrency" +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args; + return m.invoke(null, p); + } + } + }; -function EtsGlobalInitPlaceholder() {} +function EtsGlobalInitPlaceholder() { } function Bar() { return createFooClassFromTs(JSRuntime.newJSValueInt(42)); @@ -29,8 +40,9 @@ function Bar() { function checkInteropNegative(): boolean { CoroutineExtras.setSchedulingPolicy(CoroutineExtras.POLICY_NON_MAIN); EtsGlobalInitPlaceholder(); + try { - launch JSValue>(Bar).Await(); + (launch(Bar)! as Job).Await(); } catch (e: NoInteropContextError) { return true; } diff --git a/static_core/plugins/ets/tests/interop_js/tests/promise/resolve_js_promise_from_non_main_coro_test.ets b/static_core/plugins/ets/tests/interop_js/tests/promise/resolve_js_promise_from_non_main_coro_test.ets index a5b1438ceb06356009cd6793a21a048ceda9615f..d5b80f55982a902788c99f45912f4d49280e6b3f 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/promise/resolve_js_promise_from_non_main_coro_test.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/promise/resolve_js_promise_from_non_main_coro_test.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import {CoroutineExtras, AtomicFlag, launch} from "std/debug/concurrency" +import {CoroutineExtras, AtomicFlag} from "std/debug/concurrency" class Test { checkIfPromiseInJs(): boolean { @@ -62,6 +62,19 @@ function testPromiseResolve(value: int): Promise { globalResolver = resolve; }); CoroutineExtras.setSchedulingPolicy(CoroutineExtras.POLICY_NON_MAIN); - launch int>(resolverFunction, value); + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + }; + launch(resolverFunction, value); return p; } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/interop_js/tests/promise/schedule_main_coro.ets b/static_core/plugins/ets/tests/interop_js/tests/promise/schedule_main_coro.ets index 2b942d0cbe2c1a5a11fe2e690dd74b937cd8e111..cd63221c30c4d74ccc71d2731792450190a9172e 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/promise/schedule_main_coro.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/promise/schedule_main_coro.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { launch } from "std/concurrency" import { Job } from "std/core" let was_scheduled = false; @@ -40,6 +39,19 @@ function foo() { function waitUntillJsIsReady() { CoroutineExtras.setSchedulingPolicy(CoroutineExtras.POLICY_NON_MAIN); - let p = launch void>(foo); + let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + }; + let p = launch(foo) as Job; asyncFoo(p); } diff --git a/static_core/plugins/ets/tests/interop_js/tests/timer/timer_tests.ets b/static_core/plugins/ets/tests/interop_js/tests/timer/timer_tests.ets index 7c985fdae51423d32c66763f8d32b7b434ff04e6..5fdb3e4819888192c72f24db83b0b12b27f0dc66 100644 --- a/static_core/plugins/ets/tests/interop_js/tests/timer/timer_tests.ets +++ b/static_core/plugins/ets/tests/interop_js/tests/timer/timer_tests.ets @@ -13,6 +13,19 @@ * limitations under the License. */ +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + class Test { constructor(numCheckpoints: int) { this.numCheckpoints = numCheckpoints; @@ -355,7 +368,7 @@ function testClearTimerCrossWorker() setTimeout(() => { while (!isCleared.get()) {} }, 0); return setTimeout(() => { assertTrue(false); }, delay); }; - let id = launch number>(workerTimerCb).Await(); + let id = (launch(workerTimerCb) as Job).Await(); clearTimeout(id); isCleared.set(true); } @@ -365,7 +378,7 @@ function testClearTimerCrossWorker() let triedToClear = false; let id = setTimeout(() => { assertTrue(triedToClear); }, delay); try { - launch void>(clearTimeout, id).Await(); + (launch(clearTimeout, id) as Job).Await(); } catch (e) { assertEQ(e.toString(), "Error: Failed to clear timer. Unable to clear interop timer from non-interop worker"); triedToClear = true; diff --git a/static_core/plugins/ets/tests/native/exclusive_worker/exclusive_worker_tests.ets b/static_core/plugins/ets/tests/native/exclusive_worker/exclusive_worker_tests.ets index 5b948696e26fcfd5dd2301b21f83b223c2bdbd65..500adc092e23e8773c57279057f872b00ec18795 100644 --- a/static_core/plugins/ets/tests/native/exclusive_worker/exclusive_worker_tests.ets +++ b/static_core/plugins/ets/tests/native/exclusive_worker/exclusive_worker_tests.ets @@ -13,11 +13,24 @@ * limitations under the License. */ -import { launch } from "std/concurrency" let workerId = -1; let counter = 0; +let launch = (func: Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if (m.getName() == "launch") { + let p: FixedArray = new NullishType[2]; + p[0] = func; + let r = args as FixedArray; + p[1] = r; + return m.invoke(null, p); + } + } + } + function setWorkerId(eworkerId: int) { workerId = eworkerId; @@ -43,7 +56,7 @@ function asyncCall(): boolean { // LaunchCallMethod function launchCall(): boolean { - let p = launch boolean>(call); + let p = launch(call) as Job; return p.Await(); } @@ -77,7 +90,7 @@ function mainRoutine() { eWorkerLaunchEvent.wait(); mainEvent.fire(); } - launch void>(l); + launch(l); } function eWorkerRoutine(): boolean { @@ -90,7 +103,7 @@ function eWorkerRoutine(): boolean { mainEvent.wait(); eWorkerAsyncEvent.fire(); } - launch void>(l); + launch(l); return true; } @@ -104,7 +117,7 @@ function clearCounter() { function scheduleACoroutine(): boolean { clearCounter(); - launchvoid>(():void => { + launch(():void => { add(5); }); Coroutine.Schedule(); @@ -112,7 +125,7 @@ function scheduleACoroutine(): boolean { } async function asyncAdd(a: int) { - launchvoid>(():void => { + launch(():void => { add(6); }); counter += a; @@ -126,12 +139,12 @@ function scheduleAJCoroutine(): boolean { } function launchCallWithoutAwait(): Job { - return launchboolean>(call) as Job; + return launch(call) as Job; } // recursive launch function recursiveLaunch(): boolean { - let res : Job> = launch, ()=>Job>(launchCallWithoutAwait) as Job>; + let res : Job> = launch(launchCallWithoutAwait) as Job>; return res.Await().Await(); } @@ -154,12 +167,12 @@ function launchAsyncFunctions(): Promise { } function ACoroutineCallAsyncFunctions(): boolean { - let res : Job> = launch, ()=>Promise>(launchAsyncFunctions) as Job> + let res : Job> = launch(launchAsyncFunctions) as Job> return await res.Await(); } async function asyncFunctionLaunchCall() { - return launchboolean>(call); + return launch(call) as Job; } function asyncFunctionLaunchACoroutine(): boolean { @@ -175,7 +188,7 @@ function body(): Object { function testOOM(): boolean { try { for (let i = 0; i < 50000; ++i) { - launchObject>(body); + launch(body); } } catch (e) { if (e instanceof OutOfMemoryError) { @@ -192,7 +205,7 @@ function testOOM(): boolean { function test_stack_overflow(): boolean { try { - launchObject | null>(coro_stack_overflow).Await(); + (launch(coro_stack_overflow) as Job).Await(); console.println("No exceptions thrown by coro_stack_overflow() but should be!") return false; } catch (e) { @@ -219,7 +232,7 @@ function coro_error(): Object { function test_error(): boolean { try { - let res = launchObject>(coro_error); + let res = launch(coro_error) as Job; res.Await(); console.println("No exceptions thrown by coro_error() but should be!") return false; @@ -247,7 +260,7 @@ let e2m: LinkedBlockingQueue = new LinkedBlockingQueue(); let m2e: LinkedBlockingQueue = new LinkedBlockingQueue(); function EACoroutineSendToMain(): boolean { - launchvoid>(():void => { + launch(():void => { e2m.push(true); }); return m2e.pop(); diff --git a/static_core/plugins/ets/tests/native/sync_primitives/queue_spinlock_tests.ets b/static_core/plugins/ets/tests/native/sync_primitives/queue_spinlock_tests.ets index 595014f34eec138732f110ee85832e1e0133d616..4889f51eeb2197b5062289c0e026dc4debbfe1c3 100644 --- a/static_core/plugins/ets/tests/native/sync_primitives/queue_spinlock_tests.ets +++ b/static_core/plugins/ets/tests/native/sync_primitives/queue_spinlock_tests.ets @@ -13,6 +13,19 @@ * limitations under the License. */ +let launch = (func : Function, ...args: FixedArray) => { + let tp = Type.resolve("std.concurrency.ETSGLOBAL") as ClassType; + for (let i = 0; i < tp!.getMethodsNum(); i++) { + const m = tp!.getMethod(i) + if(m.getName() == "launch") { + let p : FixedArray = new NullishType[2]; + p[0] = func; + p[1] = args ; + return m.invoke(null, p) ; + } + } + } + native function spinlockCreate(): Object; native function spinlockGuard(spinlock: Object, callback: Object): void; native function spinlockIsHeld(spinlock: Object): boolean; @@ -25,7 +38,7 @@ function runConcurrently(coroutinesCount: number, callback: () => void) { return true; }; for (let i = 0; i < coroutinesCount; ++i) { - let j = launch boolean>(guard); + let j = launch(guard) as Job; jobs.push(j); } for (let job of jobs) {