soar_thread_worker 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/soar_thread_worker/thread_worker.rb +17 -14
- data/lib/soar_thread_worker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12278b63bb40751f6cf5aad90c30df6e6bdbc288
|
4
|
+
data.tar.gz: b821b7ff647ad3e481b8952a5648639cdc5d87ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f072de35033b8eed503613858ddddea4b2ae5166462ad80b3780723417ac873b615d4ec1b8475c0fe172e59d913cd0d7c99e43aa0d1e1b9e37ea1e8a30b28e04
|
7
|
+
data.tar.gz: ba9bfe7e14e1cad90cc2927a96144f124545836d257f45d16f3a6b34b42dfe0acdb0a729cb154ce2a03f9d69412677f8eb938b99efb7f7bf2d6bf90ac56fbfa1
|
@@ -11,29 +11,33 @@ module SoarThreadWorker
|
|
11
11
|
$stderr.puts "ERROR [ThreadWorker] #{message}"
|
12
12
|
end
|
13
13
|
|
14
|
-
def initialize(event_handler)
|
15
|
-
@
|
14
|
+
def initialize(event_handler: nil)
|
15
|
+
@api_mutex = Mutex.new
|
16
16
|
@stopping = false
|
17
17
|
@event_handler = event_handler
|
18
18
|
end
|
19
19
|
|
20
20
|
def running?
|
21
|
-
@
|
21
|
+
(not @thread.nil?) and @thread.alive?
|
22
22
|
end
|
23
23
|
|
24
24
|
def start
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
@api_mutex.synchronize {
|
26
|
+
begin
|
27
|
+
return if (running?)
|
28
|
+
@stopping = false
|
29
|
+
create_thread()
|
30
|
+
rescue Exception => e
|
31
|
+
ThreadWorker::error("Exception #{e} in start")
|
32
|
+
end
|
33
|
+
}
|
32
34
|
end
|
33
35
|
|
34
|
-
def stop
|
35
|
-
@
|
36
|
-
|
36
|
+
def stop(immediate: false)
|
37
|
+
@api_mutex.synchronize {
|
38
|
+
@stopping = true
|
39
|
+
@thread.kill if (not @thread.nil?) and immediate
|
40
|
+
}
|
37
41
|
end
|
38
42
|
|
39
43
|
def execute
|
@@ -50,7 +54,6 @@ module SoarThreadWorker
|
|
50
54
|
stop if execute
|
51
55
|
be_nice
|
52
56
|
end
|
53
|
-
@running = false
|
54
57
|
end
|
55
58
|
|
56
59
|
def create_thread
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soar_thread_worker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernst van Graan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|