- 判定是否在微信中打开
def wechat?
request.user_agent =~ /MicroMessenger/i
end
- 分别调用 微信网页扫码 或 公众号授权
def wechat?
request.user_agent =~ /MicroMessenger/i
end
require 'thread' # for Mutex: Ruby doesn't provide out of the box thread-safe arrays | |
class ThreadPool | |
def initialize(max_threads = 10) | |
@pool = SizedQueue.new(max_threads) | |
max_threads.times{ @pool << 1 } | |
@mutex = Mutex.new | |
@running_threads = [] | |
end |