• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { launch } from "std/concurrency"
17import { Job } from "std/core"
18
19// This test covers case of storing Promises returned from launch instruction
20// into array for different modes: INT, AOT, JIT
21
22class TestCoroutine {
23    public static threadsCount: int = 2;
24    public static jArray: (Job<Object> | null)[] = [null, null];
25
26    public jCor(): Job<Object> {
27        const factory = () => {return new Object();}
28        return launch<Object, () => Object>(factory);
29    }
30
31    public run(): void {
32        for(let i = 0; i < TestCoroutine.threadsCount; i++) {
33            TestCoroutine.jArray[i] = this.jCor();
34        }
35        Coroutine.Schedule();
36    }
37}
38
39function main(): void {
40    let a = new TestCoroutine();
41    a.run();
42}