green 0.0.1 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: green
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: '0.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-09 00:00:00.000000000Z
13
- dependencies: []
12
+ date: 2012-12-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: kgio
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.7.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.7.4
14
30
  description: Cooperative multitasking fo Ruby
15
31
  email: ceo@prepor.ru
16
32
  executables: []
@@ -20,21 +36,39 @@ extra_rdoc_files:
20
36
  files:
21
37
  - Gemfile
22
38
  - Gemfile.lock
39
+ - README.md
23
40
  - Rakefile
24
- - Readme.md
25
41
  - app.ru
26
42
  - green.gemspec
43
+ - lib/active_record/connection_adapters/green_mysql2_adapter.rb
27
44
  - lib/green-em/em-http.rb
28
45
  - lib/green.rb
46
+ - lib/green/activerecord.rb
47
+ - lib/green/connection_pool.rb
29
48
  - lib/green/event.rb
30
49
  - lib/green/ext.rb
31
50
  - lib/green/group.rb
32
51
  - lib/green/hub.rb
33
52
  - lib/green/hub/em.rb
53
+ - lib/green/hub/nio4r.rb
34
54
  - lib/green/monkey.rb
55
+ - lib/green/mysql2.rb
35
56
  - lib/green/semaphore.rb
36
- - lib/green/tcp_socket.rb
37
- - README.md
57
+ - lib/green/socket.rb
58
+ - lib/green/zmq.rb
59
+ - spec/green/activerecord_spec.rb
60
+ - spec/green/connection_pool_spec.rb
61
+ - spec/green/event_spec.rb
62
+ - spec/green/group_spec.rb
63
+ - spec/green/monkey_spec.rb
64
+ - spec/green/mysql2_spec.rb
65
+ - spec/green/semaphore_spec.rb
66
+ - spec/green/socket_spec.rb
67
+ - spec/green/tcpsocket_spec.rb
68
+ - spec/green/zmq_spec.rb
69
+ - spec/green_spec.rb
70
+ - spec/helpers.rb
71
+ - spec/spec_helper.rb
38
72
  homepage: http://github.com/prepor/green
39
73
  licenses: []
40
74
  post_install_message:
@@ -48,6 +82,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
82
  - - ! '>='
49
83
  - !ruby/object:Gem::Version
50
84
  version: '0'
85
+ segments:
86
+ - 0
87
+ hash: 1130764657698221389
51
88
  required_rubygems_version: !ruby/object:Gem::Requirement
52
89
  none: false
53
90
  requirements:
@@ -56,9 +93,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
93
  version: '0'
57
94
  requirements: []
58
95
  rubyforge_project: green
59
- rubygems_version: 1.8.10
96
+ rubygems_version: 1.8.24
60
97
  signing_key:
61
98
  specification_version: 2
62
99
  summary: Cooperative multitasking fo Ruby
63
- test_files: []
64
- has_rdoc:
100
+ test_files:
101
+ - spec/green/activerecord_spec.rb
102
+ - spec/green/connection_pool_spec.rb
103
+ - spec/green/event_spec.rb
104
+ - spec/green/group_spec.rb
105
+ - spec/green/monkey_spec.rb
106
+ - spec/green/mysql2_spec.rb
107
+ - spec/green/semaphore_spec.rb
108
+ - spec/green/socket_spec.rb
109
+ - spec/green/tcpsocket_spec.rb
110
+ - spec/green/zmq_spec.rb
111
+ - spec/green_spec.rb
data/Readme.md DELETED
@@ -1,55 +0,0 @@
1
- Cooperative multitasking for Ruby. Proof of concept.
2
-
3
- Based on Ruby 1.9 Fibers, but unlike EM::Synchrony it uses symmetric coroutines (only #current and #transfer used) and HUB-orientend architecture. So coroutines transfer control to HUB and HUB transfer control to coroutines. Coroutines never tranfer control to each other.
4
-
5
- In comparison with EM-Synchrony it allows:
6
- - develop real complex cooperative multitasking apps;
7
- - timeouts. Yes, in common case you cannot add timeout with EM-Synchrony;
8
- - kill greens. And it safe unlike kill Threads;
9
- - works with REPL and debugger. EM-Synchrony uses Fiber.yield, so you cannot run nothing in REPL;
10
- - works with every environment. You can run nonblock web-applications with Unicorn;
11
- - compatible with Ruby's Enumerator and with any other uses of Fibers themself (see https://github.com/igrigorik/em-synchrony/issues/114)
12
-
13
- ```ruby
14
- require 'green'
15
- require 'green/group'
16
- require 'green-em/em-http'
17
-
18
- g = Green::Pool.new(size: 2)
19
-
20
- urls = ['http://google.com', 'http://yandex.ru']
21
-
22
- results = g.enumerator(urls) do |url|
23
- EventMachine::HttpRequest.new(url).get
24
- end.map { |i| i.response }
25
-
26
- p results
27
- ```
28
-
29
- You can run it from Irb! ;)
30
-
31
- You can add timeout:
32
-
33
- ```ruby
34
- require 'green'
35
- require 'green/group'
36
- require 'green-em/em-http'
37
-
38
- g = Green::Pool.new(size: 2)
39
-
40
- urls = ['http://google.com', 'http://yandex.ru']
41
-
42
- begin
43
- Green.timeout(1) do
44
- results = g.enumerator(urls) do |url|
45
- EventMachine::HttpRequest.new(url).get
46
- end.map { |i| i.response }
47
- p results
48
- end
49
- rescue Timeout::Error
50
- p "Timeout!"
51
- end
52
- ```
53
-
54
- And much more soon ;)
55
-
@@ -1,25 +0,0 @@
1
- class Green
2
- class Socket < ::Socket
3
- def accept
4
- accept_nonblock
5
- end
6
-
7
- def connect(sock_addr)
8
- connect_nonblock(sock_addr)
9
- end
10
-
11
- def send(mesg, flags = 0, dest_sockaddr = nil)
12
- super(mesg, flags, dest_sockaddr)
13
- rescue Errno::EAGAIN => e
14
- wait_write
15
- retry
16
- end
17
-
18
- def recv(maxlen, flags = 0)
19
- super(maxlen, flags = 0)
20
- rescue Errno::EAGAIN => e
21
- wait_read
22
- retry
23
- end
24
- end
25
- end