Timer is just crazy.
parent
57ce9d2e38
commit
fd62919770
|
@ -16,10 +16,4 @@ class IPC::Client < IPC::Context
|
||||||
# Very important as there are filesystem side-effects.
|
# Very important as there are filesystem side-effects.
|
||||||
at_exit { close }
|
at_exit { close }
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(name : String, &block : Proc(IPC::Event::Events|Exception, Nil))
|
|
||||||
initialize name
|
|
||||||
::loop &block
|
|
||||||
close
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,13 +15,19 @@ class IPC::Context
|
||||||
def initialize(@context : LibIPC::Ctx)
|
def initialize(@context : LibIPC::Ctx)
|
||||||
end
|
end
|
||||||
|
|
||||||
# By default, this is a client.
|
def initialize(name : String, &block : Proc(IPC::Event::Events|Exception, Nil))
|
||||||
def initialize(service_name : String, &block)
|
initialize name
|
||||||
initialize(name)
|
::loop &block
|
||||||
yield self
|
|
||||||
close
|
close
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# By default, this is a client.
|
||||||
|
# def initialize(service_name : String, &block)
|
||||||
|
# initialize(name)
|
||||||
|
# yield self
|
||||||
|
# close
|
||||||
|
# end
|
||||||
|
|
||||||
# def << (client : IPC::Connection)
|
# def << (client : IPC::Connection)
|
||||||
# r = LibIPC.ipc_add(self.pointer, client.pointer, pointerof(client.pollfd))
|
# r = LibIPC.ipc_add(self.pointer, client.pointer, pointerof(client.pollfd))
|
||||||
# if r.error_code != 0
|
# if r.error_code != 0
|
||||||
|
|
|
@ -2,9 +2,9 @@ require "./client"
|
||||||
|
|
||||||
# the server is a client with a different init function
|
# the server is a client with a different init function
|
||||||
# ipc_connection => ipc_server_init
|
# ipc_connection => ipc_server_init
|
||||||
class IPC::Server < IPC::Client
|
class IPC::Server < IPC::Context
|
||||||
def initialize(name : String)
|
def initialize(name : String)
|
||||||
super
|
initialize()
|
||||||
r = LibIPC.ipc_server_init(self.pointer, name)
|
r = LibIPC.ipc_server_init(self.pointer, name)
|
||||||
if r.error_code != 0
|
if r.error_code != 0
|
||||||
m = String.new r.error_message.to_slice
|
m = String.new r.error_message.to_slice
|
||||||
|
@ -16,42 +16,14 @@ class IPC::Server < IPC::Client
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class IPC::Service < IPC::Context
|
# # TODO: replacing IPC::Service by the IPC::NetworkD class?
|
||||||
@service_info : IPC::Server
|
# class IPC::SwitchingService < IPC::Server
|
||||||
|
# property switch = IPC::Switch.new
|
||||||
def initialize(name : String)
|
#
|
||||||
@service_info = IPC::Server.new name
|
# # automatic removal of the fd in the switching list
|
||||||
super()
|
# def remove_fd (fd : Int)
|
||||||
end
|
# super
|
||||||
|
# @switch.del fd
|
||||||
def initialize(name : String, &block : Proc(IPC::Event::Events|Exception, Nil))
|
# end
|
||||||
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
|
# 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
|
|
||||||
|
|
||||||
|
|
Reference in New Issue