zold 0.13.18 → 0.13.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 803822a36daa76dbf38f3ee899fac369268b6f4c
4
- data.tar.gz: 5a5a326d4b076e6906dc15e7930291d9cb8e9d4e
3
+ metadata.gz: 95dd6bbdccf72324cc861ebb29f6825d23bce93c
4
+ data.tar.gz: b34a5fb43a224631fda4f53b87e8ca8216253c2b
5
5
  SHA512:
6
- metadata.gz: 37506ab72e6affb6f9b8b46786608fae5726ad70f390bd309954b3f495d78e00b7f88b3d12a7a08ad9c81f1ff6bad268c4fe729e0db9d9e90adb832b4be64254
7
- data.tar.gz: d516c13ac21efa8a51daffa5cae34009f5716886a77f4c96959f0af9dbcc9b7bb53036eb51cb5aa91f7518fc01c62abb4ee132470923d55db48ce72f8d57194f
6
+ metadata.gz: 28f4bb01e0856b74017923a941373df4098883e94c6e2c1cd72ae061cfb26a7985ad012095874878663663460e0ddc6b738ec4d6cc0575c0a610cb70805f9b94
7
+ data.tar.gz: 67bdc25fd68c191257169d29b7d12e1bc1c1b56becff6385e6470784c572c72ef2e07eb12bd42a7d9aa5b787fce8536d914bc0b0f9a70159094df688e8b4e019
@@ -73,7 +73,16 @@ module Zold
73
73
  end
74
74
  end
75
75
  end
76
- @log.info("Farm started with #{threads} threads at #{host}:#{port}, strength is #{strength}")
76
+ @threads << Thread.new do
77
+ VerboseThread.new(@log).run do
78
+ Thread.current.name = 'farm-cleaner'
79
+ loop do
80
+ sleep(60)
81
+ clean(host, port, strength, threads)
82
+ end
83
+ end
84
+ end
85
+ @log.info("Farm started with #{@threads.count} threads at #{host}:#{port}, strength is #{strength}")
77
86
  return unless block_given?
78
87
  begin
79
88
  yield
@@ -95,12 +104,17 @@ module Zold
95
104
 
96
105
  private
97
106
 
98
- def cycle(host, port, strength, threads)
99
- if @scores.length < threads
107
+ def clean(host, port, strength, threads)
108
+ if @scores.length < threads || @best.count < threads
100
109
  zero = Score.new(Time.now, host, port, @invoice, strength: strength)
101
110
  @scores << zero
102
111
  @best << zero
103
112
  end
113
+ @best = @best.reject(&:expired?).sort_by(&:value).reverse.take(threads)
114
+ end
115
+
116
+ def cycle(host, port, strength, threads)
117
+ clean(host, port, strength, threads)
104
118
  s = @scores.pop
105
119
  return unless s.valid?
106
120
  return unless s.host == host
@@ -112,7 +126,7 @@ module Zold
112
126
  save(n)
113
127
  @best << n
114
128
  after = @best.map(&:value).max
115
- @best = @best.reject(&:expired?).sort_by(&:value).reverse.take(threads)
129
+ clean(host, port, strength, threads)
116
130
  @log.debug("#{Thread.current.name}: best score is #{@best[0]}") if before != after && !after.zero?
117
131
  end
118
132
  @scores << n
data/lib/zold/version.rb CHANGED
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Zold
26
- VERSION = '0.13.18'.freeze
26
+ VERSION = '0.13.19'.freeze
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.18
4
+ version: 0.13.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko