module Roma::Event::EMConnection

Attributes

ap[RW]
connected[R]
fiber[W]
last_access[RW]

Public Instance Methods

gets() click to toggle source
   # File lib/roma/event/con_pool.rb
65 def gets
66   while(@connected) do
67     if idx = @rbuf.index("\n")
68       return pop(idx+1)
69     else
70       Fiber.yield(@rbuf.size)
71     end
72   end
73   nil
74 end
pop(size) click to toggle source
   # File lib/roma/event/con_pool.rb
42 def pop(size)
43   if @rbuf.size >= size
44     r = @rbuf[0..size-1]
45     @rbuf = @rbuf[size..-1]
46     r
47   else
48     nil
49   end
50 end
post_init() click to toggle source
   # File lib/roma/event/con_pool.rb
17 def post_init
18   @rbuf = ''
19   @connected = true
20   @last_access = Time.now
21 end
read_bytes(size) click to toggle source
   # File lib/roma/event/con_pool.rb
52 def read_bytes(size)
53   while(@connected) do
54     d = pop(size)
55     if d
56       return d
57     else
58       remain = size - @rbuf.size
59       Fiber.yield(remain)
60     end
61   end
62   nil
63 end
receive_data(data) click to toggle source
   # File lib/roma/event/con_pool.rb
23 def receive_data(data)
24   @rbuf << data
25   @fiber.resume
26 rescue =>e
27   Roma::Logging::RLogger.instance.error("#{__FILE__}:#{__LINE__}:#{e.inspect} #{$@}")
28 end
send(data) click to toggle source
   # File lib/roma/event/con_pool.rb
38 def send(data)
39   send_data(data)
40 end
unbind() click to toggle source
   # File lib/roma/event/con_pool.rb
30 def unbind
31   @connected = nil
32   @fiber.resume
33 rescue FiberError
34 rescue =>e
35   Roma::Logging::RLogger.instance.warn("#{__FILE__}:#{__LINE__}:#{e.inspect} #{$@}")
36 end