Sha256: 95710ff90335a9da7461dd0342bf17e885292de7bb246953875dfbf77596d5c9

Contents?: true

Size: 298 Bytes

Versions: 4

Compression:

Stored size: 298 Bytes

Contents

require 'thread'
require 'fcntl'

module Hydra
  class ThreadsafeIO < IO
    def initialize(existing_io)
      fd = existing_io.fcntl(Fcntl::F_DUPFD)
      super(fd)
      @mutex = Mutex.new
    end

    def write(*args)
      @mutex.synchronize do
        super(*args)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
arturop-hydra-0.24.0 lib/hydra/threadsafe_io.rb
nulogy-hydra-0.23.2.1 lib/hydra/threadsafe_io.rb
justinf-hydra-0.23.8 lib/hydra/threadsafe_io.rb
justinf-hydra-0.23.7 lib/hydra/threadsafe_io.rb