Browse Source

This is not needed at this stage, it will be needed later as we integrate rust and libuv.

Revert "Allow blocking open the uv loop so that it will not prematurely shut down"

This reverts commit 03c61dc8c5a48b47bb7f4033cb5195b8318af8ed.
Caleb James DeLisle 1 năm trước cách đây
mục cha
commit
456bd0293c

+ 0 - 4
util/events/EventBase.h

@@ -32,8 +32,4 @@ void EventBase_beginLoop(struct EventBase* eventBase);
 
 void EventBase_endLoop(struct EventBase* eventBase);
 
-void EventBase_ref();
-
-void EventBase_unref();
-
 #endif

+ 2 - 27
util/events/libuv/EventBase.c

@@ -37,9 +37,6 @@ static int onFree(struct Allocator_OnFreeJob* job)
         EventBase_endLoop((struct EventBase*) ctx);
         return Allocator_ONFREE_ASYNC;
     } else {
-        if (!uv_is_closing((uv_handle_t*) &ctx->blockTimer)) {
-            uv_close((uv_handle_t*) &ctx->blockTimer, NULL);
-        }
         uv_loop_delete(ctx->loop);
         return 0;
     }
@@ -65,15 +62,11 @@ static void calibrateTime(struct EventBase_pvt* base)
     base->baseTime = (seconds * 1000) + milliseconds - uv_now(base->loop);
 }
 
-static _Atomic int EventBase_refctr = 0;
-
 struct EventBase* EventBase_new(struct Allocator* allocator)
 {
     struct Allocator* alloc = Allocator_child(allocator);
     struct EventBase_pvt* base = Allocator_calloc(alloc, sizeof(struct EventBase_pvt), 1);
     base->loop = uv_loop_new();
-    uv_timer_init(base->loop, &base->blockTimer);
-    Assert_true(EventBase_refctr == 0);
     base->alloc = alloc;
     Identity_set(base);
 
@@ -82,11 +75,6 @@ struct EventBase* EventBase_new(struct Allocator* allocator)
     return &base->pub;
 }
 
-static void doNothing(uv_timer_t* handle, int status)
-{
-    // title says it all
-}
-
 void EventBase_beginLoop(struct EventBase* eventBase)
 {
     struct EventBase_pvt* ctx = Identity_check((struct EventBase_pvt*) eventBase);
@@ -94,18 +82,12 @@ void EventBase_beginLoop(struct EventBase* eventBase)
     Assert_true(!ctx->running); // double begin
     ctx->running = 1;
 
-    do {
-        uv_timer_start(&ctx->blockTimer, doNothing, 1, 0);
-        // start the loop.
-        uv_run(ctx->loop, UV_RUN_DEFAULT);
-    } while (EventBase_refctr);
+    // start the loop.
+    uv_run(ctx->loop, UV_RUN_DEFAULT);
 
     ctx->running = 0;
 
     if (ctx->onFree) {
-        if (!uv_is_closing((uv_handle_t*) &ctx->blockTimer)) {
-            uv_close((uv_handle_t*) &ctx->blockTimer, NULL);
-        }
         uv_loop_delete(ctx->loop);
         Allocator_onFreeComplete(ctx->onFree);
         return;
@@ -138,10 +120,3 @@ struct EventBase_pvt* EventBase_privatize(struct EventBase* base)
 {
     return Identity_check((struct EventBase_pvt*) base);
 }
-
-void EventBase_ref() {
-    EventBase_refctr++;
-}
-void EventBase_unref() {
-    EventBase_refctr--;
-}

+ 0 - 4
util/events/libuv/EventBase_pvt.h

@@ -26,10 +26,6 @@ struct EventBase_pvt
 
     uv_loop_t* loop;
 
-    // This little guy keeps the loop looping as long as there's
-    // something else happening in Rust/tokio.
-    uv_timer_t blockTimer;
-
     struct Allocator* alloc;
 
     /** True if the loop is running. */