pigeon 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/pigeon/engine.rb +2 -2
- data/lib/pigeon/processor.rb +19 -25
- data/pigeon.gemspec +10 -24
- metadata +31 -48
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.1
|
data/lib/pigeon/engine.rb
CHANGED
@@ -235,7 +235,7 @@ class Pigeon::Engine
|
|
235
235
|
# Schedules a block for execution on the main EventMachine thread. This is
|
236
236
|
# a wrapper around the EventMachine.schedule method.
|
237
237
|
def self.execute_in_main_thread(&block)
|
238
|
-
EventMachine.
|
238
|
+
EventMachine.next_tick(&block)
|
239
239
|
end
|
240
240
|
|
241
241
|
# == Instance Methods =====================================================
|
@@ -356,7 +356,7 @@ class Pigeon::Engine
|
|
356
356
|
|
357
357
|
target_queue.perform(&block)
|
358
358
|
else
|
359
|
-
EventMachine.
|
359
|
+
EventMachine.next_tick(&block)
|
360
360
|
end
|
361
361
|
end
|
362
362
|
|
data/lib/pigeon/processor.rb
CHANGED
@@ -19,7 +19,6 @@ class Pigeon::Processor
|
|
19
19
|
# can be given to filter the tasks contained in the associated queue.
|
20
20
|
def initialize(queue = nil, context = nil, &filter)
|
21
21
|
@id = Pigeon::Support.unique_id
|
22
|
-
@lock = Mutex.new
|
23
22
|
@filter = filter
|
24
23
|
@context = context
|
25
24
|
|
@@ -39,18 +38,14 @@ class Pigeon::Processor
|
|
39
38
|
|
40
39
|
if (@queue = queue)
|
41
40
|
@claim = lambda do |task|
|
42
|
-
if (@
|
43
|
-
|
44
|
-
@task = queue.claim(task)
|
41
|
+
if (!@task and (!@filter or @filter.call(task)))
|
42
|
+
@task = queue.claim(task)
|
45
43
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
44
|
+
before_task(@task)
|
45
|
+
|
46
|
+
@task.run!(self) do
|
47
|
+
switch_to_next_task!
|
51
48
|
end
|
52
|
-
|
53
|
-
@lock.unlock
|
54
49
|
end
|
55
50
|
end
|
56
51
|
|
@@ -87,21 +82,20 @@ protected
|
|
87
82
|
# Used to reliably switch to the next task and coordinates the required
|
88
83
|
# hand-off from one to the next.
|
89
84
|
def switch_to_next_task!
|
90
|
-
@
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
85
|
+
if (@task)
|
86
|
+
after_task(@task)
|
87
|
+
|
88
|
+
@task.processor = nil
|
89
|
+
|
96
90
|
@task = nil
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
91
|
+
end
|
92
|
+
|
93
|
+
if (@queue)
|
94
|
+
if (@task = @queue.pop(&@filter))
|
95
|
+
before_task(@task)
|
96
|
+
|
97
|
+
@task.run!(self) do
|
98
|
+
switch_to_next_task!
|
105
99
|
end
|
106
100
|
end
|
107
101
|
end
|
data/pigeon.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.7.
|
7
|
+
s.name = "pigeon"
|
8
|
+
s.version = "0.7.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["tadman"]
|
12
|
+
s.date = "2011-10-12"
|
13
|
+
s.description = "Pigeon is a simple way to get started building an EventMachine engine that's intended to run as a background job."
|
14
|
+
s.email = "github@tadman.ca"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
17
|
"README.rdoc"
|
@@ -50,24 +50,10 @@ Gem::Specification.new do |s|
|
|
50
50
|
"test/unit/pigeon_task_test.rb",
|
51
51
|
"test/unit/pigeon_test.rb"
|
52
52
|
]
|
53
|
-
s.homepage =
|
54
|
-
s.require_paths = [
|
55
|
-
s.rubygems_version =
|
56
|
-
s.summary =
|
57
|
-
s.test_files = [
|
58
|
-
"test/helper.rb",
|
59
|
-
"test/unit/pigeon_backlog_test.rb",
|
60
|
-
"test/unit/pigeon_dispatcher_test.rb",
|
61
|
-
"test/unit/pigeon_engine_test.rb",
|
62
|
-
"test/unit/pigeon_launcher_test.rb",
|
63
|
-
"test/unit/pigeon_option_accessor_test.rb",
|
64
|
-
"test/unit/pigeon_processor_test.rb",
|
65
|
-
"test/unit/pigeon_queue_test.rb",
|
66
|
-
"test/unit/pigeon_scheduler_test.rb",
|
67
|
-
"test/unit/pigeon_sorted_array_test.rb",
|
68
|
-
"test/unit/pigeon_task_test.rb",
|
69
|
-
"test/unit/pigeon_test.rb"
|
70
|
-
]
|
53
|
+
s.homepage = "http://github.com/twg/pigeon"
|
54
|
+
s.require_paths = ["lib"]
|
55
|
+
s.rubygems_version = "1.8.10"
|
56
|
+
s.summary = "Simple daemonized EventMachine engine framework with plug-in support"
|
71
57
|
|
72
58
|
if s.respond_to? :specification_version then
|
73
59
|
s.specification_version = 3
|
metadata
CHANGED
@@ -1,38 +1,36 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pigeon
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.1
|
4
5
|
prerelease:
|
5
|
-
version: 0.7.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- tadman
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-10-12 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: eventmachine
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2154594780 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
24
22
|
type: :development
|
25
|
-
|
26
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2154594780
|
25
|
+
description: Pigeon is a simple way to get started building an EventMachine engine
|
26
|
+
that's intended to run as a background job.
|
27
27
|
email: github@tadman.ca
|
28
28
|
executables: []
|
29
|
-
|
30
29
|
extensions: []
|
31
|
-
|
32
|
-
extra_rdoc_files:
|
30
|
+
extra_rdoc_files:
|
33
31
|
- LICENSE
|
34
32
|
- README.rdoc
|
35
|
-
files:
|
33
|
+
files:
|
36
34
|
- .document
|
37
35
|
- LICENSE
|
38
36
|
- README.rdoc
|
@@ -67,41 +65,26 @@ files:
|
|
67
65
|
- test/unit/pigeon_test.rb
|
68
66
|
homepage: http://github.com/twg/pigeon
|
69
67
|
licenses: []
|
70
|
-
|
71
68
|
post_install_message:
|
72
69
|
rdoc_options: []
|
73
|
-
|
74
|
-
require_paths:
|
70
|
+
require_paths:
|
75
71
|
- lib
|
76
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
73
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version:
|
82
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
79
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version:
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
88
84
|
requirements: []
|
89
|
-
|
90
85
|
rubyforge_project:
|
91
|
-
rubygems_version: 1.8.
|
86
|
+
rubygems_version: 1.8.10
|
92
87
|
signing_key:
|
93
88
|
specification_version: 3
|
94
89
|
summary: Simple daemonized EventMachine engine framework with plug-in support
|
95
|
-
test_files:
|
96
|
-
- test/helper.rb
|
97
|
-
- test/unit/pigeon_backlog_test.rb
|
98
|
-
- test/unit/pigeon_dispatcher_test.rb
|
99
|
-
- test/unit/pigeon_engine_test.rb
|
100
|
-
- test/unit/pigeon_launcher_test.rb
|
101
|
-
- test/unit/pigeon_option_accessor_test.rb
|
102
|
-
- test/unit/pigeon_processor_test.rb
|
103
|
-
- test/unit/pigeon_queue_test.rb
|
104
|
-
- test/unit/pigeon_scheduler_test.rb
|
105
|
-
- test/unit/pigeon_sorted_array_test.rb
|
106
|
-
- test/unit/pigeon_task_test.rb
|
107
|
-
- test/unit/pigeon_test.rb
|
90
|
+
test_files: []
|