ruby_channel 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  .bundle
4
+ doc
5
+ doc/*
6
+ drafts.rb
data/README CHANGED
@@ -1,7 +1,46 @@
1
+ = Ruby Channel - The power of Go Channels in Ruby
2
+
1
3
  This is a simple library aimed to use channels in Ruby the same concept that channels in Google's Go.
2
4
 
3
- Missing tests and decent README? Read the very simple code!
4
5
 
5
- Shame on me!
6
+ == Install
7
+
8
+ gem install ruby_channel
9
+
10
+
11
+ == Usage
12
+
13
+ This is the simplest example:
14
+
15
+ include RubyChannel
16
+
17
+ chan = Channel.new
18
+ chan << 'data'
19
+ chan.pop # => 'data'
20
+
21
+ Now something more interesting:
22
+
23
+ include RubyChannel
24
+ chan = [Channel.new, Channel.new]
25
+
26
+ Thread.new{ chan[rand 2] << 'where data goes?' }
27
+
28
+ select_channel do |s|
29
+ s.listen(chan[0]){ |data| puts data; puts 'On channel zero!' }
30
+ s.listen(chan[1]){ |data| puts data; puts 'On channel one!' }
31
+ end
32
+
33
+
34
+ == Documentation
35
+
36
+ Look at http://rdoc.info/gems/ruby_channel
37
+
38
+
39
+ == TODO
40
+
41
+ * Tests (Shame on me!)
42
+
43
+
44
+ == License
6
45
 
7
46
  MIT license... bla, bla, bla
@@ -49,8 +49,8 @@ module RubyChannel
49
49
  end
50
50
 
51
51
  #
52
- # Retrieves data from channel like method +pop+, but if +non_block+ is true, the
53
- # thread isn't suspended, and an exception is raised.
52
+ # Retrieves data from channel like method +pop+, but if thread isn't suspended,
53
+ # and an exception is raised.
54
54
  #
55
55
  def pop!
56
56
  @mutex.synchronize do
@@ -46,7 +46,7 @@ module RubyChannel
46
46
  @mutex.sleep
47
47
  end
48
48
  end
49
- @threads.each{ |thread| thread.wakeup }
49
+ @threads.each{ |thread| thread.wakeup if thread.alive? }
50
50
  @threads.clear
51
51
  return @result
52
52
  end
@@ -1,3 +1,3 @@
1
1
  module RubyChannel
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dalton Pinto
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-09 00:00:00 -02:00
17
+ date: 2011-02-10 00:00:00 -02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency