sixpool 0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/sixpool.rb +30 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 02bc44cb89fba71a302658cb460b43b8b384abeb
4
+ data.tar.gz: 6a3a05434b334ce314283f2697621b4a16adc912
5
+ SHA512:
6
+ metadata.gz: cf7e289e1a4563350076551c010459e1e3d7eb0c6cda7f95479ca8c7cb30ed61f2a30eb2356c7551883667a0621070b810335a7fb79b3c2ebd56e230fa229902
7
+ data.tar.gz: 73130df9ea042790b8c3817cc607123f96620eb0cf7afc958974893072106ba36fb5f4df2bea49c99ed67cbe4b6fd0481ab80d170d95ba1429344fa179c9f4d6
data/lib/sixpool.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'thread'
2
+
3
+ class Sixpool
4
+ def initialize(size=6)
5
+ @size = size
6
+ @jobs = Queue.new
7
+ @pool = Array.new(@size) do |i|
8
+ Thread.new do
9
+ Thread.current[:id] = i
10
+ catch(:exit) do
11
+ loop do
12
+ job, args = @jobs.pop
13
+ job.call(*args)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ def attack(*args, &block)
21
+ @jobs << [block, args]
22
+ end
23
+
24
+ def gg
25
+ @size.times do
26
+ attack { throw :exit }
27
+ end
28
+ @pool.map(&:join)
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sixpool
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Shayne Parmelee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple but effective way to thread tasks in Ruby
14
+ email: shayne.parmelee@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/sixpool.rb
20
+ homepage: http://rubygems.org/gems/sixpool
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.14.1
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Threading with Starcraft words
44
+ test_files: []