• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 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 
16 #ifndef ECMASCRIPT_JOBS_MICRO_JOB_QUEUE_H
17 #define ECMASCRIPT_JOBS_MICRO_JOB_QUEUE_H
18 
19 #include "ecmascript/js_function.h"
20 #include "ecmascript/js_handle.h"
21 #include "ecmascript/js_thread.h"
22 #include "ecmascript/record.h"
23 #include "ecmascript/tagged_array.h"
24 
25 namespace panda::ecmascript::job {
26 class MicroJobQueue final : public Record {
27 public:
Cast(TaggedObject * object)28     static MicroJobQueue *Cast(TaggedObject *object)
29     {
30         ASSERT(JSTaggedValue(object).IsMicroJobQueue());
31         return static_cast<MicroJobQueue *>(object);
32     }
33 
34     static uint32_t GetPromiseQueueSize(JSThread *thread, JSHandle<MicroJobQueue> jobQueue);
35     static void EnqueueJob(JSThread *thread, JSHandle<MicroJobQueue> jobQueue, QueueType queueType,
36         const JSHandle<JSFunction> &job, const JSHandle<TaggedArray> &argv);
37     static void ExecutePendingJob(JSThread *thread, JSHandle<MicroJobQueue> jobQueue);
38 
39     static constexpr size_t PROMISE_JOB_QUEUE_OFFSET = Record::SIZE;
40     ACCESSORS(PromiseJobQueue, PROMISE_JOB_QUEUE_OFFSET, SCRIPT_JOB_QUEUE_OFFSET);
41     ACCESSORS(ScriptJobQueue, SCRIPT_JOB_QUEUE_OFFSET, SIZE);
42 
43     DECL_DUMP()
44 
45     DECL_VISIT_OBJECT(PROMISE_JOB_QUEUE_OFFSET, SIZE)
46 };
47 }  // namespace panda::ecmascript::job
48 #endif  // ECMASCRIPT_JOBS_MICRO_JOB_QUEUE_H
49