From 2b0508e5402f71171ab83d20a792474e7985e239 Mon Sep 17 00:00:00 2001 From: Vladimir Kochnev Date: Fri, 21 Aug 2015 16:29:42 +0300 Subject: [PATCH] Synchronize redis operations with task-aware latch. --- lib/celluloid/redis.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/celluloid/redis.rb b/lib/celluloid/redis.rb index 4648b0e..7accc54 100644 --- a/lib/celluloid/redis.rb +++ b/lib/celluloid/redis.rb @@ -1,3 +1,19 @@ require "redis" require "celluloid/redis/version" +require "celluloid/io" + +module Celluloid + class Redis < ::Redis + VERSION = CelluloidRedis::VERSION + + def synchronize + if @options[:driver] == :celluloid + @latch ||= Celluloid::IO::Stream::Latch.new + @latch.synchronize { yield @client } + else + super(&proc) + end + end + end +end