File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -81,11 +81,11 @@ def initialize(tag_prefix = nil, *args)
8181 @socket_path = options [ :socket_path ]
8282 @nanosecond_precision = options [ :nanosecond_precision ]
8383
84- factory = MessagePack ::Factory . new
84+ @ factory = MessagePack ::Factory . new
8585 if @nanosecond_precision
86- factory . register_type ( EventTime ::TYPE , EventTime )
86+ @ factory. register_type ( EventTime ::TYPE , EventTime )
8787 end
88- @packer = factory . packer
88+ @packer = @ factory. packer
8989
9090 @mon = Monitor . new
9191 @pending = nil
@@ -182,9 +182,11 @@ def pending_bytesize
182182
183183 def to_msgpack ( msg )
184184 begin
185- res = @packer . pack ( msg ) . to_s
186- @packer . clear
187- res
185+ @mon . synchronize {
186+ res = @packer . pack ( msg ) . to_s
187+ @packer . clear
188+ res
189+ }
188190 rescue NoMethodError
189191 JSON . parse ( JSON . generate ( msg ) ) . to_msgpack
190192 end
You can’t perform that action at this time.
0 commit comments