Skip to content

Instantly share code, notes, and snippets.

@dineshsprabu
Last active February 27, 2018 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dineshsprabu/0016c3a557d900b3be5a79131704fae2 to your computer and use it in GitHub Desktop.
Save dineshsprabu/0016c3a557d900b3be5a79131704fae2 to your computer and use it in GitHub Desktop.
[Ruby] Sticky Thread Pool
# 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