Module: Rubigraph
- Defined in:
- lib/rubigraph.rb
Overview
Ruby wrapper for Ubigraph.
Call Rubigraph.init at first.
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.2.0'
Class Method Summary collapse
- .call(*argv) ⇒ Object
-
.clear ⇒ Object
clear all vertex, edges.
- .flush! ⇒ Object
- .genid ⇒ Object
-
.init(host = '127.0.0.1', port = '20738', ttl = 1) ⇒ Object
initialize XML-RPC client.
Class Method Details
.call(*argv) ⇒ Object
189 190 191 192 193 194 |
# File 'lib/rubigraph.rb', line 189 def self.call(*argv) @mutex.synchronize { @pool.push argv } flush! if @pool.size >= 256 end |
.clear ⇒ Object
clear all vertex, edges
170 171 172 173 |
# File 'lib/rubigraph.rb', line 170 def self.clear call('ubigraph.clear') flush! end |
.flush! ⇒ Object
175 176 177 178 179 180 |
# File 'lib/rubigraph.rb', line 175 def self.flush! @mutex.synchronize { @server.multicall(*@pool) @pool.clear } end |
.genid ⇒ Object
182 183 184 185 186 187 |
# File 'lib/rubigraph.rb', line 182 def self.genid @mutex.synchronize { @num += 1 } @num end |
.init(host = '127.0.0.1', port = '20738', ttl = 1) ⇒ Object
initialize XML-RPC client
155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/rubigraph.rb', line 155 def self.init(host='127.0.0.1', port='20738',ttl=1) @server = XMLRPC::Client.new2("http://#{host}:#{port}/RPC2") @mutex = Mutex.new @pool = Array.new @num = -1 * (1 << 31) - 1 # XMLPRC i4's minimum @flusher = Thread.start(ttl) do |ttl| while true do sleep ttl flush! end end at_exit { flush! } end |