Class: Fluent::Counter::Future

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/counter/client.rb

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

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

#dataObject



268
269
270
# File 'lib/fluent/counter/client.rb', line 268

def data
  get.data
end

#errorsObject



259
260
261
# File 'lib/fluent/counter/client.rb', line 259

def errors
  get.errors
end

#errors?Boolean

Returns:

  • (Boolean)


263
264
265
266
# File 'lib/fluent/counter/client.rb', line 263

def errors?
  es = errors
  es && !es.empty?
end

#getObject



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

#waitObject



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