Sha256: 0e0d91329e16e302b691dcdbb6f11ad4f3c662e1172fdddbdea41af1fd48aef3
Contents?: true
Size: 1.07 KB
Versions: 6
Compression:
Stored size: 1.07 KB
Contents
module Plezi module_function # DANGER ZONE - Plezi Engine. the io reactor mutex IO_LOCKER = Mutex.new # Plezi Engine, DO NOT CALL. waits on IO and pushes events. all threads hang while reactor is active (unless events are already 'in the pipe'.) def io_reactor IO_LOCKER.synchronize do return false unless EVENTS.empty? united = SERVICES.keys + IO_CONNECTION_DIC.keys return false if united.empty? io_r = (IO.select(united, nil, united, idle_sleep) ) #rescue false) if io_r io_r[0].each do |io| if SERVICES[io] begin connection = io.accept_nonblock callback Plezi, :add_connection, connection, SERVICES[io] rescue Errno::EWOULDBLOCK => e rescue Exception => e error e # SERVICES.delete s if s.closed? end elsif IO_CONNECTION_DIC[io] callback(IO_CONNECTION_DIC[io], :on_message) else IO_CONNECTION_DIC.delete(io) SERVICES.delete(io) end end io_r[2].each { |io| (IO_CONNECTION_DIC.delete(io) || SERVICES.delete(io)).close rescue true } end end true end end
Version data entries
6 entries across 6 versions & 1 rubygems