From 77026a249a2760f26f9fadd0ef2791ffa7828edf Mon Sep 17 00:00:00 2001 From: Karchnu Date: Fri, 3 Jul 2020 22:41:07 +0200 Subject: [PATCH] timer --- src/ipc.cr | 9 ++++++++- src/ipc/context.cr | 8 ++++---- src/json.cr | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ipc.cr b/src/ipc.cr index ac6ff8a..02cc134 100644 --- a/src/ipc.cr +++ b/src/ipc.cr @@ -1 +1,8 @@ -require "./ipc/*" +require "./ipc/lowlevel.cr" +require "./ipc/exception.cr" +require "./ipc/message.cr" +require "./ipc/event.cr" +require "./ipc/switch.cr" +require "./ipc/context.cr" +require "./ipc/client.cr" +require "./ipc/service.cr" diff --git a/src/ipc/context.cr b/src/ipc/context.cr index 1619d39..5989a77 100644 --- a/src/ipc/context.cr +++ b/src/ipc/context.cr @@ -83,11 +83,11 @@ class IPC::Context end def loop(&block : Proc(IPC::Event::Events|Exception, Nil)) - if @base_timer > 0 && @timer == 0 - @timer = @base_timer - end - ::loop do + if @base_timer > 0 && @timer == 0 + @timer = @base_timer + end + yield wait_event &block end end diff --git a/src/json.cr b/src/json.cr index 034f95c..a4fbdaf 100644 --- a/src/json.cr +++ b/src/json.cr @@ -25,7 +25,7 @@ class IPC::JSON end end -class IPC::Connection +class IPC::Context def send(message : IPC::JSON) send message.type.to_u8, message.to_json end