Class: Watson::Conversation::FutureData

Inherits:
Object
  • Object
show all
Defined in:
lib/watson/conversation.rb

Instance Method Summary collapse

Constructor Details

#initializeFutureData

Returns a new instance of FutureData.



58
59
60
61
62
63
64
# File 'lib/watson/conversation.rb', line 58

def initialize()
	@is_ready = false
	@real_data = nil

	@mutex = Mutex.new
	@cv = ConditionVariable.new
end

Instance Method Details

#get_dataObject



81
82
83
84
85
86
87
88
# File 'lib/watson/conversation.rb', line 81

def get_data()
	@mutex.synchronize do
		while @is_ready == false
			@cv.wait(@mutex)
		end
	end
	return @real_data
end

#set_real_data(code, body) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/watson/conversation.rb', line 67

def set_real_data(code, body)
	@mutex.synchronize do
		if @is_ready == true
			return
		end
	end
	
	@real_data = code, body
	@is_ready = true

	@cv.broadcast
end