distributor 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,6 @@
1
1
  require "distributor"
2
2
  require "distributor/okjson"
3
3
  require "distributor/packet"
4
- require "thread"
5
4
 
6
5
  class Distributor::Multiplexer
7
6
 
@@ -9,7 +8,6 @@ class Distributor::Multiplexer
9
8
  @output = output
10
9
  @readers = Hash.new { |hash,key| hash[key] = StringIO.new }
11
10
  @writers = Hash.new { |hash,key| hash[key] = StringIO.new }
12
- @write_lock = Mutex.new
13
11
 
14
12
  @output.sync = true
15
13
  end
@@ -38,9 +36,7 @@ class Distributor::Multiplexer
38
36
  end
39
37
 
40
38
  def output(ch, data)
41
- @write_lock.synchronize do
42
- Distributor::Packet.write(@output, ch, data)
43
- end
39
+ Distributor::Packet.write(@output, ch, data)
44
40
  rescue Errno::EPIPE
45
41
  end
46
42
 
@@ -20,15 +20,17 @@ class Distributor::Packet
20
20
  end
21
21
 
22
22
  def self.parse(io)
23
- header = io.read(4)
24
- return if header.nil?
25
- raise "invalid header" unless header == "DIST"
26
- version = unpack(io.read(4))
27
- channel = unpack(io.read(4))
28
- length = unpack(io.read(4))
29
- data = io.read(length)
30
-
31
- [ channel, data ]
23
+ @@input ||= Mutex.new
24
+ @@input.synchronize do
25
+ header = io.read(4)
26
+ return if header.nil?
27
+ raise "invalid header" unless header == "DIST"
28
+ version = unpack(io.read(4))
29
+ channel = unpack(io.read(4))
30
+ length = unpack(io.read(4))
31
+ data = io.read(length)
32
+ return [ channel, data ]
33
+ end
32
34
  end
33
35
 
34
36
  def self.pack(num)
@@ -1,5 +1,5 @@
1
1
  module Distributor
2
2
 
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: distributor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70092817757520 !ruby/object:Gem::Requirement
16
+ requirement: &70284552374260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.13.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70092817757520
24
+ version_requirements: *70284552374260
25
25
  description: TCP Multiplexer
26
26
  email: ddollar@gmail.com
27
27
  executables: []