em-nodes 0.5.1 → 0.5.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63bf7a640509b5d505dab58cd5e3b05a876cf3fe
4
- data.tar.gz: a661ef9b96da2ebffe719f4d0b119854d200bcad
3
+ metadata.gz: 15f186e1f26c19bcc23b349732640afc79b9bb86
4
+ data.tar.gz: 3a9c86de3c9dd34df08b5c8eb2ad90876cf609b5
5
5
  SHA512:
6
- metadata.gz: d05d3cd9556e979bccc301b61d4096c9fcd24a26699b8af2e7f21c3f501ace11b2356a49c698e43c33c10bdd296cddb7e545171bcb3e3e70df814b06f92814b4
7
- data.tar.gz: 28c387f119f1da47370cabcf64904b9f4824a507e7244a3d969340dd44169859dde9d9d64c0dbdef887a07fc3ab930079bb8ad5e13b2a4966fb23208db20dde7
6
+ metadata.gz: d76be1f7c858e4d0fc15da1b680ffacd0ab989df17b39cc86d98c1a3a08ca1d2872dfe6ffeefe36f9c243445305099dfa92f92f9bb753d23bcd1d415e3f26410
7
+ data.tar.gz: bfe232231ed284e231f19df0d5412f7c8bdf8b51c2069cbebd96cb96ce8e83b46d421ed21dd22bd6c33edb5e8d0fc58f58dc99e8a18bc8cab7112c08cfde1c9c
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - "ree"
4
+ - "1.9.3"
5
+ - "2.0.0"
6
+ - "2.1"
7
+ - "2.2"
8
+ - "rbx"
9
+ - "jruby"
@@ -11,6 +11,10 @@ class EM::Nodes::Client < EM::Connection
11
11
  @alive = true
12
12
  end
13
13
 
14
+ def alive?
15
+ @alive
16
+ end
17
+
14
18
  def unbind
15
19
  @alive = false
16
20
  EM::Nodes.logger.warn { "Connection has terminated" }
@@ -1,5 +1,10 @@
1
1
  class EM::Nodes::Client
2
2
  module TaskFeature
3
+ def initialize(*args)
4
+ super(*args)
5
+ @mutex = Mutex.new
6
+ @tasks_hash = {}
7
+ end
3
8
 
4
9
  def on_task(task_id, data)
5
10
  # redefine me
@@ -7,19 +12,19 @@ class EM::Nodes::Client
7
12
  end
8
13
 
9
14
  def tasks
10
- @tasks ||= {}
15
+ @tasks_hash.values
11
16
  end
12
17
 
13
18
  def send_task_result(task_id, result)
14
19
  send_task_result_internal(task_id, result)
15
- tasks.delete(task_id)
20
+ @mutex.synchronize { @tasks_hash.delete(task_id) }
16
21
  end
17
22
 
18
23
  private
19
24
 
20
25
  def on_task_internal(task_id, data)
21
26
  obj = on_task(task_id, data)
22
- tasks[task_id] = obj
27
+ @mutex.synchronize { @tasks_hash[task_id] = obj }
23
28
  end
24
29
  end
25
30
  end
@@ -2,5 +2,5 @@ module EventMachine
2
2
  end
3
3
 
4
4
  module EventMachine::Nodes
5
- VERSION = "0.5.1"
5
+ VERSION = "0.5.27"
6
6
  end
@@ -31,8 +31,9 @@ end
31
31
  describe "Base spec" do
32
32
  it "base callbacks should work" do
33
33
  EM.run do
34
- $server0 = Server0.start('/tmp/_emn_server0')
35
- $client0 = Client0.connect('/tmp/_emn_server0')
34
+ host, port = (RUBY_PLATFORM =~ /java/) ? ['127.0.0.1', 19999] : ['/tmp/emn_server0.sock']
35
+ $server0 = Server0.start(host, port)
36
+ $client0 = Client0.connect(host, port)
36
37
 
37
38
  EM.next_tick do
38
39
  $client0.bla.should == 1
@@ -26,6 +26,6 @@ describe "Simple spec" do
26
26
  $client22.send_ping(2)
27
27
  end
28
28
 
29
- $pong.should == [2, 3]
29
+ $pong.sort.should == [2, 3]
30
30
  end
31
31
  end
@@ -3,3 +3,6 @@ require 'bundler/setup'
3
3
  Bundler.require
4
4
 
5
5
  EM::Nodes.logger = Logger.new(File.dirname(__FILE__) + "/spec.log")
6
+ RSpec.configure do |config|
7
+ config.expect_with(:rspec) { |c| c.syntax = :should }
8
+ end
@@ -45,11 +45,12 @@ describe "write task object, to prevent GC" do
45
45
  EM.add_timer(0.5) do
46
46
  $server5_results.should be_empty
47
47
  $client5.tasks.size.should == 10
48
- $client5.tasks.values.map(&:time).compact.size.should == 10
48
+ $client5.tasks.map(&:time).compact.size.should == 10
49
49
  end
50
50
  end
51
51
 
52
52
  $server5_results.size.should == 10
53
53
  $client5.tasks.size.should == 0
54
+ $client5.tasks.is_a?(Array).should == true
54
55
  end
55
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-nodes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'Konstantin Makarchev'"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-06 00:00:00.000000000 Z
11
+ date: 2015-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -76,6 +76,7 @@ extra_rdoc_files: []
76
76
  files:
77
77
  - ".gitignore"
78
78
  - ".rspec"
79
+ - ".travis.yml"
79
80
  - Gemfile
80
81
  - LICENSE.txt
81
82
  - README.md
@@ -139,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
140
  version: '0'
140
141
  requirements: []
141
142
  rubyforge_project:
142
- rubygems_version: 2.2.2
143
+ rubygems_version: 2.4.7
143
144
  signing_key:
144
145
  specification_version: 4
145
146
  summary: Simple abstraction on top of EventMachine for easy create clients, servers,