pigeon 0.6.5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.5
1
+ 0.7.0
@@ -39,6 +39,9 @@ class Pigeon::Engine
39
39
  /var/log
40
40
  /tmp
41
41
  ].freeze
42
+ option_accessor :threaded,
43
+ :boolean => true,
44
+ :default => false
42
45
 
43
46
  attr_reader :id
44
47
 
@@ -348,9 +351,13 @@ class Pigeon::Engine
348
351
  # queue has a large number of threads, while the named queues default
349
352
  # to only one so they can be processed sequentially.
350
353
  def dispatch(name = :default, &block)
351
- target_queue = @dispatcher[name] ||= Pigeon::Dispatcher.new(name == :default ? nil : 1)
352
-
353
- target_queue.perform(&block)
354
+ if (self.threaded?)
355
+ target_queue = @dispatcher[name] ||= Pigeon::Dispatcher.new(name == :default ? nil : 1)
356
+
357
+ target_queue.perform(&block)
358
+ else
359
+ EventMachine.schedule(&block)
360
+ end
354
361
  end
355
362
 
356
363
  class << self
@@ -39,7 +39,7 @@ class Pigeon::Processor
39
39
 
40
40
  if (@queue = queue)
41
41
  @claim = lambda do |task|
42
- @lock.synchronize do
42
+ if (@lock.try_lock)
43
43
  if (!@task and (!@filter or @filter.call(task)))
44
44
  @task = queue.claim(task)
45
45
 
@@ -49,6 +49,8 @@ class Pigeon::Processor
49
49
  switch_to_next_task!
50
50
  end
51
51
  end
52
+
53
+ @lock.unlock
52
54
  end
53
55
  end
54
56
 
@@ -37,10 +37,6 @@ module Pigeon::Support
37
37
  exit(-1)
38
38
  end
39
39
  end
40
-
41
- wfd.puts(daemon_pid)
42
- wfd.flush
43
- wfd.close
44
40
 
45
41
  begin
46
42
  Process.wait(daemon_pid)
@@ -50,6 +46,8 @@ module Pigeon::Support
50
46
  relaunch = ($? != 0)
51
47
 
52
48
  rescue Interrupt
49
+ Process.kill('INT', daemon_pid)
50
+
53
51
  relaunch = false
54
52
  end
55
53
 
@@ -62,6 +60,10 @@ module Pigeon::Support
62
60
  end
63
61
  end
64
62
  end
63
+
64
+ wfd.puts(supervisor_pid)
65
+ wfd.flush
66
+ wfd.close
65
67
  end
66
68
 
67
69
  Process.wait(forked_pid)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pigeon}
8
- s.version = "0.6.5"
8
+ s.version = "0.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{tadman}]
12
- s.date = %q{2011-05-15}
12
+ s.date = %q{2011-06-21}
13
13
  s.description = %q{Pigeon is a simple way to get started building an EventMachine engine that's intended to run as a background job.}
14
14
  s.email = %q{github@tadman.ca}
15
15
  s.extra_rdoc_files = [
@@ -52,7 +52,7 @@ Gem::Specification.new do |s|
52
52
  ]
53
53
  s.homepage = %q{http://github.com/twg/pigeon}
54
54
  s.require_paths = [%q{lib}]
55
- s.rubygems_version = %q{1.8.2}
55
+ s.rubygems_version = %q{1.8.5}
56
56
  s.summary = %q{Simple daemonized EventMachine engine framework with plug-in support}
57
57
  s.test_files = [
58
58
  "test/helper.rb",
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: pigeon
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.5
5
+ version: 0.7.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - tadman
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-15 00:00:00 Z
13
+ date: 2011-06-21 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: eventmachine
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  requirements: []
89
89
 
90
90
  rubyforge_project:
91
- rubygems_version: 1.8.2
91
+ rubygems_version: 1.8.5
92
92
  signing_key:
93
93
  specification_version: 3
94
94
  summary: Simple daemonized EventMachine engine framework with plug-in support