Move the job queue from the ports into jerry-core (#1804)

* Move the job queue from the ports into jerry-core

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu

* Remove port notification and keep `jerry_run_all_enqueued_jobs` API only

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss
2017-05-18 11:30:50 +02:00
committed by yichoi
parent 0806c16902
commit 23068bdf99
12 changed files with 155 additions and 175 deletions
+36
View File
@@ -757,6 +757,42 @@ jerry_eval (const jerry_char_t *source_p,
- [jerry_create_external_function](#jerry_create_external_function)
- [jerry_external_handler_t](#jerry_external_handler_t)
## jerry_run_all_enqueued_jobs
**Summary**
Run enqueued Promise jobs until the first thrown error or until all get executed.
**Prototype**
```c
jerry_value_t
jerry_run_all_enqueued_jobs (void)
```
- return value - result of last executed job, may be error value.
**Example**
```c
{
jerry_init (JERRY_INIT_EMPTY);
const jerry_char_t script[] = "new Promise(function(f,r) { f('Hello, World!'); }).then(function(x) { print(x); });";
size_t script_size = strlen ((const char *) script);
jerry_value_t parsed_code = jerry_parse (script, script_size, false);
jerry_value_t script_value = jerry_run (parsed_code);
jerry_value_t job_value = jerry_run_all_enqueued_jobs ();
jerry_release_value (job_value);
jerry_release_value (script_value);
jerry_release_value (parsed_code);
jerry_cleanup ();
}
```
# Get the global context