Lines Matching refs:loop

35loop that contains **uvloop**, we plan to normalize the event loops in the application model to a…
37 Avoid using the libuv NDK to perform operations on the application main loop obtained by **napi_get…
47 …only one event loop can exist in a thread. To ensure proper running of the main event loop of the …
55 Call **napi_get_uv_event_loop()** to obtain the system loop, and use libuv NDK APIs to implement re…
78 uv_loop_s *loop = nullptr;
80 napi_get_uv_event_loop(env, &loop);
82 int ret = uv_queue_work(loop, work, execute, complete);
126 uv_loop_t *loop;
171 #### Scenario 2: The libuv API does not work when throwing an FD event to the main loop of the appl…
173loop of the application receives only FD events, and executes **uv_run** only after **backend_fd**…
188 uv_loop_t *loop;
203 // Obtain the event loop.
204 napi_get_uv_event_loop(env, &loop);
210 uv_poll_init(loop, poll_handle, fd);
274 uv_loop_t *loop;
290 napi_get_uv_event_loop(env, &loop);
295 uv_poll_init(loop, poll_handle, fd);
299 uv_async_send(&loop->wq_async);
340 …that depend on **uv_run** do not work as expected in the application main loop of the current syst…
458loop thread (the thread that initializes the loop using **uv_loop_init**), and all non-thread-safe…
460 …ces, it is recommended that the same thread be used for creating an event loop and executing **uv_…
464 …onstraints vary depending on the source of the loop. Specifically, you can create a loop or obtain…
468loop or call **uv_loop_init** to initialize a loop. (You need to manage the lifecycle of the loop.…
470 If tasks have to be thrown from other threads to the loop thread, use **uv_async_send**. Specifical…
484 auto loop = handle->loop;
486 uv_timer_init(loop, timer);
501 std::thread t ([] () { // Thread A, loop thread
502 uv_loop_t* loop = new uv_lppo_t;
503 // Create a loop and manage the loop lifecycle.
504 uv_loop_init(loop);
506 uv_async_init(loop, async, timer_cb);
507 // Start the loop.
508 uv_run(loop, UV_RUN_DEFAULT);
511 loop,
519 while (uv_run(loop, UV_RUN_DEFAULT) != 0);
520 // Release the loop.
521 uv_loop_delete(loop);
530 …uv_async_send (async); // Call uv_async_send to instruct the loop thread to call timer_cb bound to…
562 …ed to the task queue from a non-loop thread. Then, **uv_async_send** is called at appropriate time…
566 Generally, the loop obtained from **env** using **napi_get_uv_event_loop** is an event loop of a JS…
568loop thread due to service requirements, use the thread-safe function **uv_async_send**. Specifica…
582 …rwise, resource contention may occur. The best way is to call the function in an event loop thread.
596loop manages all resources of the entire event loop and runs through the lifecycle of the entire e…
600 - **UV_RUN_DEFAULT**: runs the event loop until there are no active handles or requests. This is th…
601 …ack and then skip **uv__io_poll**. In this mode, there is an event to occur in the loop by default.
608 int uv_loop_init(uv_loop_t* loop);
611 Initializes a loop.
616 int uv_loop_close(uv_loop_t* loop);
619 Closes a loop. The operation is successful only after all handles and requests in the loop are clos…
624 int uv_loop_delete(uv_loop_t* loop);
627loop. This API calls **uv_loop_close** to release all internal resources associated with the loop
639loop. In OpenHarmony, libuv loops still exist in the application main loop and other JS worker thr…
644 int uv_run(uv_loop_t* loop, uv_run_mode mode);
647 …Runs an event loop. For details about the running mode, see [Event Loop Running Modes](#event-loop
652 int uv_loop_alive(uv_loop_t loop);
655 Checks whether a loop is active.
660 void uv_stop(uv_loop_t* loop);
663 Stops an event loop. The event loop stops only in the next iteration of the loop. If this API is ca…
667 …efore **uv_stop** is called, ensure that the handles of all threads related to the loop are closed.
672 int stop_loop(uv_loop_t* loop)
674 uv_stop(loop);
683 uv_walk(loop, ensure_close, nullptr);
685 // Continue to run uv_run until there is no active handle or request in the loop.
687 if (uv_run(loop, UV_RUN_DEFAULT) == 0) {
692 // Check the loop status.
693 if (uv_loop_alive(loop) != 0) {
702 …ject, which is usually mounted to the corresponding **handle_queue** in a loop. If a handle is act…
727 - Perform the handle initialization in the event loop thread.
729 - For the handle that is no longer used, call **uv_close** to remove it from the loop.
742loop, and waits for the loop thread to run **uv__run_closing_handles**. Finally, the **close_cb** …
750 > - All handle operations cannot be called on non-loop threads by obtaining the loop of other threa…
754 … acquired must be released in the **complete()** callback executed on the loop thread. The followi…
758 uv_queue_work(loop, work, [](uv_work_t* req) {
773 uv_queue_work(loop, work, [](uv_work_t* work) {
778 uv_queue_work(loop, work, [](...) {/* do something*/}, [](...) {
793 …*eventhandler**, wait for **eventhandler** to schedule, and return to the loop thread for executio…
801 **uv_queue_work()** can be called only on the loop thread. This prevents multi-threading issues. Do…
807loop simultaneously. Otherwise, the application may crash. To use libuv APIs to operate timers, pe…
812 In the following example, operations on the timer heap of the same loop are performed in multiple t…
860 uv_loop_t* loop = nullptr;
863 napi_get_uv_event_loop(env, &loop);
864 uv_timer_init(loop, timer);
865 std::thread t1([&loop, &timer](){
912 uv_loop_t* loop = nullptr;
915 napi_get_uv_event_loop(env, &loop);
916 uv_timer_init(loop, timer);
978 auto loop = handle->loop;
980 uv_timer_init(loop, timer);
989 uv_loop_t* loop = nullptr;
990 napi_get_uv_event_loop(env, &loop);
991 uv_async_init(loop, async, timer_cb);
1036 int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb)
1045 - **loop**: pointer to the event loop.
1063 Wakes up the event loop and calls the async handle's callback.
1087 uv_loop_t* loop = nullptr;
1094 // Call uv_close to close the async handle and release the memory in the main loop.
1104 loop = uv_default_loop();
1106 uv_async_init(loop, async, async_handler);
1115 return uv_run(loop, UV_RUN_DEFAULT);
1123 3. Run the event loop on the main thread.
1156 int uv_queue_work(uv_loop_t* loop,
1169 - **after_work_cb**: callback to be executed by the loop thread.
1171 …by an FD event triggered by **uv_async_send(loop->wq_async)** and executed in the next iteration o…
1179loop, other threads use the **UV_RUN_DEFAULT** mode in libuv as the event main loop of the calling…
1187 The following types of requests can be processed as expected in the application main loop:
1195 * Adds a work request to an event loop queue.
1197 * @param loop indicates the pointer to the event loop.
1206 int uv_random(uv_loop_t* loop,
1220 * Adds a work request to an event loop queue.
1222 * work_cb will be called by a new thread in the next iteration of the event loop.
1223 * When work_cb is complete, after_work_cb will be called on the event loop thread.
1225 * @param loop indicates the pointer to the event loop.
1228 * @param after_work_cb indicates the callback to be invoked on the event loop thread.
1232 int uv_queue_work(uv_loop_t* loop,
1246 * @param loop indicates the pointer to the event loop.
1255 int uv_fs_read(uv_loop_t* loop, uv_fs_t* req,
1265 * @param loop indicates the pointer to the event loop.
1274 int uv_fs_open(uv_loop_t* loop,
1284 * @param loop indicates the pointer to the event loop.
1294 int uv_fs_sendfile(uv_loop_t* loop,
1305 * @param loop indicates the pointer to the event loop.
1315 int uv_fs_write(uv_loop_t* loop,
1326 * @param loop indicates the pointer to the event loop.
1335 int uv_fs_copyfile(uv_loop_t* loop,
1351 * @param loop indicates the pointer to the event loop.
1360 int uv_getaddrinfo(uv_loop_t* loop,
1376 * @param loop indicates the pointer to the event loop.
1384 int uv_getnameinfo(uv_loop_t* loop,