Class: Fluent::Counter::Future
- Inherits:
-
Object
- Object
- Fluent::Counter::Future
- Defined in:
- lib/fluent/counter/client.rb
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
- #data ⇒ Object
- #errors ⇒ Object
- #errors? ⇒ Boolean
- #get ⇒ Object
-
#initialize(loop, mutex) ⇒ Future
constructor
A new instance of Future.
- #set(v) ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(loop, mutex) ⇒ Future
Returns a new instance of Future.
247 248 249 250 251 252 |
# File 'lib/fluent/counter/client.rb', line 247 def initialize(loop, mutex) @set = false @result = nil @mutex = mutex @loop = loop end |
Instance Method Details
#data ⇒ Object
268 269 270 |
# File 'lib/fluent/counter/client.rb', line 268 def data get.data end |
#errors ⇒ Object
259 260 261 |
# File 'lib/fluent/counter/client.rb', line 259 def errors get.errors end |
#errors? ⇒ Boolean
263 264 265 266 |
# File 'lib/fluent/counter/client.rb', line 263 def errors? es = errors es && !es.empty? end |
#get ⇒ Object
272 273 274 275 276 |
# File 'lib/fluent/counter/client.rb', line 272 def get # Block until `set` method is called and @result is set join if @result.nil? @result end |
#set(v) ⇒ Object
254 255 256 257 |
# File 'lib/fluent/counter/client.rb', line 254 def set(v) @result = Result.new(v) @set = true end |
#wait ⇒ Object
278 279 280 281 282 283 284 |
# File 'lib/fluent/counter/client.rb', line 278 def wait res = get if res.error? Fluent::Counter.raise_error(res.errors.first) end res end |