Sha256: e3cc9227bcb1403c3d06e233cb7af860f04e8bda4acd2fc25b75f3cdf94a00fb
Contents?: true
Size: 745 Bytes
Versions: 2
Compression:
Stored size: 745 Bytes
Contents
require "rubygems" require "URI" require "curl-multi" require "thread" class Yawn def initialize @curl = Curl::Multi.new @cv = ConditionVariable.new @mutex = Mutex.new @thread = Thread.new do @mutex.synchronize do loop do while @curl.size > 0 @curl.select([], []) end @cv.wait(@mutex) end end end end def get(url, &callback) callback ||= proc {} URI.parse(url) a = @curl.get(url, callback, callback) @mutex.synchronize { @cv.signal } a end def post(url, data, &callback) callback ||= proc {} URI.parse(url) a = @curl.post(url, data, callback, callback) @mutex.synchronize { @cv.signal } a end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yawn-1.1.0 | lib/yawn.rb |
yawn-1.0.0 | lib/yawn.rb |