Last active
February 27, 2018 14:48
-
-
Save dineshsprabu/0016c3a557d900b3be5a79131704fae2 to your computer and use it in GitHub Desktop.
[Ruby] Sticky Thread Pool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sticky Thread Pool would help to execute your block | |
# by sticking to a particular executor on the pool by | |
# by index. | |
require "concurrent" | |
class StickyThreadPool | |
attr_accessor :pool | |
def initialize(size) | |
@pool = [] | |
size.times do | |
@pool << Concurrent::SingleThreadExecutor.new() | |
end | |
end | |
end | |
sthreads = StickyThreadPool.new(10) | |
puts sthreads.pool # Array of executors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment