Archived
3
0

Timer is just crazy.

This commit is contained in:
Karchnu 2020-07-03 16:23:52 +02:00
parent 57ce9d2e38
commit fd62919770
3 changed files with 22 additions and 50 deletions

View File

@ -16,10 +16,4 @@ class IPC::Client < IPC::Context
# Very important as there are filesystem side-effects.
at_exit { close }
end
def initialize(name : String, &block : Proc(IPC::Event::Events|Exception, Nil))
initialize name
::loop &block
close
end
end

View File

@ -15,13 +15,19 @@ class IPC::Context
def initialize(@context : LibIPC::Ctx)
end
# By default, this is a client.
def initialize(service_name : String, &block)
initialize(name)
yield self
def initialize(name : String, &block : Proc(IPC::Event::Events|Exception, Nil))
initialize name
::loop &block
close
end
# By default, this is a client.
# def initialize(service_name : String, &block)
# initialize(name)
# yield self
# close
# end
# def << (client : IPC::Connection)
# r = LibIPC.ipc_add(self.pointer, client.pointer, pointerof(client.pollfd))
# if r.error_code != 0

View File

@ -2,9 +2,9 @@ require "./client"
# the server is a client with a different init function
# ipc_connection => ipc_server_init
class IPC::Server < IPC::Client
class IPC::Server < IPC::Context
def initialize(name : String)
super
initialize()
r = LibIPC.ipc_server_init(self.pointer, name)
if r.error_code != 0
m = String.new r.error_message.to_slice
@ -16,42 +16,14 @@ class IPC::Server < IPC::Client
end
end
class IPC::Service < IPC::Context
@service_info : IPC::Server
def initialize(name : String)
@service_info = IPC::Server.new name
super()
end
def initialize(name : String, &block : Proc(IPC::Event::Events|Exception, Nil))
initialize name
loop &block
close
end
# sanitizer
def fd
@service_info.fd
end
# def loop(&block : Proc(IPC::Event::Events|Exception, Nil))
# super(@service_info, &block)
# end
def close
@service_info.close
end
end
# TODO: replacing IPC::Service by the IPC::NetworkD class?
class IPC::SwitchingService < IPC::Service
property switch = IPC::Switch.new
# automatic removal of the fd in the switching list
def remove_fd (fd : Int)
super
@switch.del fd
end
end
# # TODO: replacing IPC::Service by the IPC::NetworkD class?
# class IPC::SwitchingService < IPC::Server
# property switch = IPC::Switch.new
#
# # automatic removal of the fd in the switching list
# def remove_fd (fd : Int)
# super
# @switch.del fd
# end
# end