Class: Baykit::BayServer::Common::RudderState
- Inherits:
-
Object
- Object
- Baykit::BayServer::Common::RudderState
- Includes:
- Util, Util::Reusable
- Defined in:
- lib/baykit/bayserver/common/rudder_state.rb
Class Attribute Summary collapse
-
.id_counter ⇒ Object
readonly
Returns the value of attribute id_counter.
Instance Attribute Summary collapse
-
#accepting ⇒ Object
Returns the value of attribute accepting.
-
#buf_size ⇒ Object
readonly
Returns the value of attribute buf_size.
-
#bytes_read ⇒ Object
Returns the value of attribute bytes_read.
-
#bytes_wrote ⇒ Object
Returns the value of attribute bytes_wrote.
-
#closing ⇒ Object
Returns the value of attribute closing.
-
#connecting ⇒ Object
Returns the value of attribute connecting.
-
#finale ⇒ Object
Returns the value of attribute finale.
-
#handshaking ⇒ Object
Returns the value of attribute handshaking.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_access_time ⇒ Object
readonly
Returns the value of attribute last_access_time.
-
#multiplexer ⇒ Object
Returns the value of attribute multiplexer.
-
#read_buf ⇒ Object
readonly
Returns the value of attribute read_buf.
-
#reading ⇒ Object
Returns the value of attribute reading.
-
#reading_lock ⇒ Object
readonly
Returns the value of attribute reading_lock.
-
#rudder ⇒ Object
readonly
Returns the value of attribute rudder.
-
#transporter ⇒ Object
readonly
Returns the value of attribute transporter.
-
#write_queue ⇒ Object
readonly
Returns the value of attribute write_queue.
-
#write_queue_lock ⇒ Object
readonly
Returns the value of attribute write_queue_lock.
-
#writing ⇒ Object
Returns the value of attribute writing.
-
#writing_lock ⇒ Object
readonly
Returns the value of attribute writing_lock.
Instance Method Summary collapse
-
#access ⇒ Object
Custom methods.
- #end ⇒ Object
- #init(rd, tp = nil, timeout_sec = 0) ⇒ Object
-
#initialize ⇒ RudderState
constructor
A new instance of RudderState.
-
#reset ⇒ Object
Implements Reusable.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ RudderState
Returns a new instance of RudderState.
40 41 42 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 40 def initialize end |
Class Attribute Details
.id_counter ⇒ Object (readonly)
Returns the value of attribute id_counter.
12 13 14 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 12 def id_counter @id_counter end |
Instance Attribute Details
#accepting ⇒ Object
Returns the value of attribute accepting.
37 38 39 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 37 def accepting @accepting end |
#buf_size ⇒ Object (readonly)
Returns the value of attribute buf_size.
25 26 27 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 25 def buf_size @buf_size end |
#bytes_read ⇒ Object
Returns the value of attribute bytes_read.
30 31 32 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 30 def bytes_read @bytes_read end |
#bytes_wrote ⇒ Object
Returns the value of attribute bytes_wrote.
31 32 33 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 31 def bytes_wrote @bytes_wrote end |
#closing ⇒ Object
Returns the value of attribute closing.
23 24 25 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 23 def closing @closing end |
#connecting ⇒ Object
Returns the value of attribute connecting.
38 39 40 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 38 def connecting @connecting end |
#finale ⇒ Object
Returns the value of attribute finale.
35 36 37 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 35 def finale @finale end |
#handshaking ⇒ Object
Returns the value of attribute handshaking.
27 28 29 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 27 def handshaking @handshaking end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
16 17 18 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 16 def id @id end |
#last_access_time ⇒ Object (readonly)
Returns the value of attribute last_access_time.
22 23 24 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 22 def last_access_time @last_access_time end |
#multiplexer ⇒ Object
Returns the value of attribute multiplexer.
20 21 22 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 20 def multiplexer @multiplexer end |
#read_buf ⇒ Object (readonly)
Returns the value of attribute read_buf.
24 25 26 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 24 def read_buf @read_buf end |
#reading ⇒ Object
Returns the value of attribute reading.
28 29 30 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 28 def reading @reading end |
#reading_lock ⇒ Object (readonly)
Returns the value of attribute reading_lock.
33 34 35 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 33 def reading_lock @reading_lock end |
#rudder ⇒ Object (readonly)
Returns the value of attribute rudder.
18 19 20 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 18 def rudder @rudder end |
#transporter ⇒ Object (readonly)
Returns the value of attribute transporter.
19 20 21 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 19 def transporter @transporter end |
#write_queue ⇒ Object (readonly)
Returns the value of attribute write_queue.
26 27 28 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 26 def write_queue @write_queue end |
#write_queue_lock ⇒ Object (readonly)
Returns the value of attribute write_queue_lock.
32 33 34 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 32 def write_queue_lock @write_queue_lock end |
#writing ⇒ Object
Returns the value of attribute writing.
29 30 31 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 29 def writing @writing end |
#writing_lock ⇒ Object (readonly)
Returns the value of attribute writing_lock.
34 35 36 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 34 def writing_lock @writing_lock end |
Instance Method Details
#access ⇒ Object
Custom methods
101 102 103 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 101 def access @last_access_time = Time.now.tv_sec end |
#end ⇒ Object
105 106 107 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 105 def end @finale = true end |
#init(rd, tp = nil, timeout_sec = 0) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 44 def init(rd, tp = nil, timeout_sec = 0) @id = RudderState.id_counter.next @rudder = rd @transporter = tp @timeout_sec = timeout_sec if tp != nil @buf_size = tp.get_read_buffer_size @handshaking = tp.secure() ? true : false else @buf_size = 8192 @handshaking = false end @read_buf = " ".b * @buf_size @accepting = false @connecting = false @write_queue = [] @write_queue_lock = Mutex::new @reading_lock = Mutex::new @writing_lock = Mutex::new @reading = false @writing = false @bytes_read = 0 @bytes_wrote = 0 end |
#reset ⇒ Object
Implements Reusable
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 79 def reset() @id = 0 @rudder = nil @transporter = nil @multiplexer = nil @last_access_time = 0 @closing = false @read_buf.clear @write_queue = [] @bytes_read = 0 @bytes_wrote = 0 @finale = false @reading = false @writing = false @timeout_sec = 0 end |
#to_s ⇒ Object
71 72 73 74 |
# File 'lib/baykit/bayserver/common/rudder_state.rb', line 71 def to_s str = "st(rd=#{@rudder} mpx=#{@multiplexer} tp=#{@transporter})" return str end |