• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright JS Foundation and other contributors, http://js.foundation
2  *
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 ECMA_JOB_QUEUE_H
17 #define ECMA_JOB_QUEUE_H
18 
19 #if ENABLED (JERRY_ES2015_BUILTIN_PROMISE)
20 
21 /** \addtogroup ecma ECMA
22  * @{
23  *
24  * \addtogroup ecmajobqueue ECMA Job Queue related routines
25  * @{
26  */
27 
28 /**
29  * Job queue item types.
30  */
31 typedef enum
32 {
33   ECMA_JOB_PROMISE_REACTION, /**< promise reaction job */
34   ECMA_JOB_PROMISE_THENABLE, /**< promise thenable job */
35 } ecma_job_queue_item_type_t;
36 
37 /**
38  * Description of the job queue item.
39  */
40 typedef struct
41 {
42   uintptr_t next_and_type; /**< next and type members of a queue item */
43 } ecma_job_queue_item_t;
44 
45 void ecma_job_queue_init (void);
46 
47 void ecma_enqueue_promise_reaction_job (ecma_value_t capability, ecma_value_t handler, ecma_value_t argument);
48 void ecma_enqueue_promise_resolve_thenable_job (ecma_value_t promise, ecma_value_t thenable, ecma_value_t then);
49 void ecma_free_all_enqueued_jobs (void);
50 
51 ecma_value_t ecma_process_all_enqueued_jobs (void);
52 
53 /**
54  * @}
55  * @}
56  */
57 #endif /* ENABLED (JERRY_ES2015_BUILTIN_PROMISE) */
58 #endif /* !ECMA_JOB_QUEUE_H */
59