thread_watcher 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f43a2fa0ddd026933d5db0a46dddd567cdc1a58d
4
- data.tar.gz: a701a0b0a633cdfa81d676d859e05ce42d44fb7d
3
+ metadata.gz: 24a83f2ca8c731586e7b68c0d202927190141cbd
4
+ data.tar.gz: e23fdb1d7220115d704a8c5c701cf9ccd09ba0cf
5
5
  SHA512:
6
- metadata.gz: b001e06a3fcb58f24673ab77af6e9e61fabffa1786dc0f8a90b32ac069f14ac15ace26f27c740d0b3b2d8e2016ce670a4e925453d89c36cce180177605b58004
7
- data.tar.gz: 6d4a65d215975df9217c9ad892eac1a32074880406ce964771ac576420aa34ef693c4997340fa5ec693c9463f35307eec3fe85da9c47c710140c15204e56a2a1
6
+ metadata.gz: c7d930125f3faefd1c125137eb67e29a4b912aff645102474ea84778ea7ddd514de295cd44e99667d9ce0f43f40fe0c9d2af73db00b39a933523e18479f4504a
7
+ data.tar.gz: 965b663ec4c2d2262ea193ff24e0dc6e0787c150203c276ce32b5b6c5296b7c5c8be198e02bd5c5023f425cee2df9014881bc18754288c41a1e797e38b2fe2d9
data/README.md CHANGED
@@ -11,7 +11,7 @@ Ruby 1.8.7 support removed in Version 1.0.0
11
11
  hm, yeah. just add this to your Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'thread_watcher', '~> 1.0.0'
14
+ gem 'thread_watcher', '~> 1.1.0'
15
15
  ```
16
16
 
17
17
  And then execute:
@@ -35,7 +35,7 @@ Something big like sleep(10) ;).
35
35
  ```
36
36
 
37
37
  Run needs a block to work and return the internal process id.
38
- This could be something like `1452333019`
38
+ This could be something like `4`
39
39
 
40
40
  If your thread is ok, so let them work.
41
41
  ThreadWatcher starts automaticly a cleaning task to kill all dead threads every minute. You can skip this feature with the option key `keep alive`
@@ -49,7 +49,7 @@ Let's say you type something like
49
49
  And you want to kill this worker. So just use the process id to kill the thread
50
50
 
51
51
  ```ruby
52
- ThreadWatcher::Monitor.kill! 1452333224
52
+ ThreadWatcher::Monitor.kill! 6
53
53
  ```
54
54
 
55
55
  Your thread is now killed.
@@ -65,11 +65,11 @@ And you get a simple overview like
65
65
 
66
66
  ```
67
67
  |ID |Running? |Runtime in Seconds |Name
68
- |1452537945 |true | 177 |Cleaning Jobs
69
- |1452538091 |false | 31 |sleeper9
70
- |1452538106 |true | 16 |noname
71
- |1452538116 |true | 6 |sleeper50
72
- |1452538121 |true | 1 |sleeper30
68
+ |4 |true | 177 |Cleaning Jobs
69
+ |5 |false | 31 |sleeper9
70
+ |7 |true | 16 |noname
71
+ |8 |true | 6 |sleeper50
72
+ |9 |true | 1 |sleeper30
73
73
 
74
74
 
75
75
  ```
@@ -93,7 +93,7 @@ Sometimes you may want to hold a process instead of automaticly killing them aft
93
93
  Now, the process won't be killed automaticly when he's done. So you can restart them with
94
94
 
95
95
  ```ruby
96
- ThreadWatcher::Monitor.restart 1452333224
96
+ ThreadWatcher::Monitor.restart 5
97
97
  ```
98
98
 
99
99
  You can also kill your process with a keep_alive option by using the `kill!` command.
@@ -4,10 +4,12 @@ module ThreadWatcher
4
4
 
5
5
  def initialize
6
6
  @threads = {}
7
+ @current_id = 1
7
8
  start_cleaning_job
8
9
  end
9
10
 
10
11
  def run options = {}, &block
12
+ options = options.merge(id: next_id)
11
13
  thread_holder = ThreadHolder.new(block, options)
12
14
  thread_holder.start!
13
15
  @threads[thread_holder.id] = thread_holder
@@ -51,6 +53,11 @@ module ThreadWatcher
51
53
 
52
54
  private
53
55
 
56
+ def next_id
57
+ @current_id += 1
58
+ @current_id
59
+ end
60
+
54
61
  def start_cleaning_job
55
62
  run(name: 'Cleaning Jobs', keep_alive: true) { while true; self.clear!; sleep(60); end; }
56
63
  end
@@ -3,8 +3,8 @@ module ThreadWatcher
3
3
  attr_accessor :thread, :id, :options, :block, :start_time
4
4
  def initialize block, options
5
5
  @block = block
6
- set_id
7
6
  @options = available_options.merge options
7
+ set_id
8
8
  end
9
9
 
10
10
  def start!
@@ -44,7 +44,7 @@ module ThreadWatcher
44
44
  end
45
45
 
46
46
  def set_id
47
- @id = start_time || time_to_i
47
+ @id = options[:id]
48
48
  end
49
49
  end
50
50
  end
@@ -1,3 +1,3 @@
1
1
  module ThreadWatcher
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thread_watcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Starke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-28 00:00:00.000000000 Z
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 2.4.6
85
+ rubygems_version: 2.5.1
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Monitor Tasks and kill or restart them from each Point of your Application.