tiny_work_service 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny_work_service.rb +9 -3
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af9afaca880e9be9ef717b24166a7c3670119bdd35cc58084edad8271da94e80
4
- data.tar.gz: 60a483d580dd54c88a584109620b40e1d728225b2229c5dfaa84806da8eb1e36
3
+ metadata.gz: 296647c2c51d68cbba82065611381d054cd8cd03040ae517091c61d293cf2482
4
+ data.tar.gz: ab47c3e2df96388dd5d3addc3149a65a2b8fe2a9b9511e4e4212bde0c37b9a04
5
5
  SHA512:
6
- metadata.gz: 1658d413a33e68eda21894c65e834d51352a2ca012183b6f1646f6b322d4f6c5c592f8b06f28ab4f9d89171088b60ba1592ede2d74e8eb5bbe50dd56e75bf0d5
7
- data.tar.gz: 5cf7b2dd07e0ebdf0f96252cdef13215faaf28e6c07167dfad03b7231487d4e956704c01c468391472b8b69df5fe786da4665035a492e698c1afe5d3fe376d24
6
+ metadata.gz: 333a4611d4cdaf81840ace4effe638e47e298fb55cea680665f31e71d28f4d68282877714dd335fd612417055ba70b3bd03771ebdfb4e03984eada8f0f00c989
7
+ data.tar.gz: 3272a5cc96178eb56cd7f84f337a26bc859a62943996a0f4ec6b3158a10aa0c0915ff2f0404004ee96056886fb8e0d04eec3543de5c9b4fc60b9009669f50e17
@@ -4,16 +4,17 @@ require 'tiny_tcp_service'
4
4
  # s = TinyWorkService.new(1234)
5
5
  # s.stop!
6
6
  class TinyWorkService
7
- def initialize(port)
7
+ def initialize(port, label='TinyWorkService')
8
8
  @service = TinyTCPService.new(port)
9
9
  @service.msg_handler = self
10
10
  @jobs = Queue.new
11
+ @label = label
11
12
 
12
- Thread.new do
13
+ @thread = Thread.new do
13
14
  loop do
14
15
  break unless @service.running?
15
16
 
16
- print "\rTinyWorkService #{@jobs.length.to_s.rjust(6)} jobs #{@service.num_clients.to_s.rjust(4)} workers\e[K"
17
+ print "\r#{@label} #{@jobs.length.to_s.rjust(6)} jobs #{@service.num_clients.to_s.rjust(4)} workers\e[K"
17
18
  sleep 0.5
18
19
  end
19
20
  end
@@ -34,6 +35,11 @@ class TinyWorkService
34
35
  end
35
36
  end
36
37
 
38
+ # join the service Thread, if you want to wait until it's done
39
+ def join
40
+ @thread.join
41
+ end
42
+
37
43
  # enqueue a job
38
44
  def <<(j)
39
45
  @jobs << j
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_work_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.3'
27
27
  description: uses the tiny_tcp_service gem to implement a job queue
28
28
  email: jefflunt@gmail.com
29
29
  executables: []