coryosborn-j_background 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/j_background.gemspec +2 -2
- data/lib/j_background/base.rb +10 -4
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/j_background.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{j_background}
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.2.0"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Cory Osborn"]
|
7
|
-
s.date = %q{2009-
|
7
|
+
s.date = %q{2009-06-07}
|
8
8
|
s.email = %q{cory@coryosborn.com}
|
9
9
|
s.extra_rdoc_files = [
|
10
10
|
"LICENSE",
|
data/lib/j_background/base.rb
CHANGED
@@ -10,10 +10,7 @@ module JBackground
|
|
10
10
|
|
11
11
|
# initializes the thread pool and defines a finalizer that forces all threads to shutdown
|
12
12
|
def initialize
|
13
|
-
@thread_pool = java.util.concurrent.Executors.newFixedThreadPool(JBackground::Base.pool_size || 5)
|
14
|
-
ObjectSpace.define_finalizer(@thread_pool) do
|
15
|
-
@thread_pool.shutdown_now
|
16
|
-
end
|
13
|
+
@thread_pool = java.util.concurrent.Executors.newFixedThreadPool(JBackground::Base.pool_size || 5, JBackgroundThreadFactory.new)
|
17
14
|
end
|
18
15
|
|
19
16
|
# singleton's instance method for executing a task
|
@@ -47,4 +44,13 @@ module JBackground
|
|
47
44
|
@@logger = value
|
48
45
|
end
|
49
46
|
end
|
47
|
+
|
48
|
+
class JBackgroundThreadFactory
|
49
|
+
include java.util.concurrent.ThreadFactory
|
50
|
+
def new_thread(runnable)
|
51
|
+
rv = java.lang.Thread.new(runnable);
|
52
|
+
rv.setDaemon(true)
|
53
|
+
rv
|
54
|
+
end
|
55
|
+
end
|
50
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coryosborn-j_background
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cory Osborn
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-07 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|