summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2017-01-11 21:32:59 +0200
committerSaku Ytti <saku@ytti.fi>2017-01-11 21:32:59 +0200
commit571b77d285afe6a9085369d46b4c57ebd58a5ca1 (patch)
treed581ba3bc5d6cfad74b5c789cc48eaacab148b56
parent88811da1a72b3f7d9ad51b54386478426aeb8bb2 (diff)
add one thread when requesting next via API
-rw-r--r--lib/oxidized/nodes.rb3
-rw-r--r--lib/oxidized/worker.rb5
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index f5a1ad0..011bfc3 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -4,7 +4,7 @@ module Oxidized
class Oxidized::NotSupported < OxidizedError; end
class Oxidized::NodeNotFound < OxidizedError; end
class Nodes < Array
- attr_accessor :source
+ attr_accessor :source, :jobs
alias :put :unshift
def load node_want=nil
with_lock do
@@ -73,6 +73,7 @@ module Oxidized
# set last job to nil so that the node is picked for immediate update
n.last = nil
put n
+ jobs.want += 1
end
end
end
diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb
index 94a13c6..1bbe26e 100644
--- a/lib/oxidized/worker.rb
+++ b/lib/oxidized/worker.rb
@@ -3,8 +3,9 @@ module Oxidized
require 'oxidized/jobs'
class Worker
def initialize nodes
- @nodes = nodes
- @jobs = Jobs.new(Oxidized.config.threads, Oxidized.config.interval, @nodes)
+ @nodes = nodes
+ @jobs = Jobs.new(Oxidized.config.threads, Oxidized.config.interval, @nodes)
+ @nodes.jobs = @jobs
Thread.abort_on_exception = true
end