Skip to content

Commit

Permalink
Replace Thread by Actor, undoing slack-ruby#224.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Sep 29, 2018
1 parent 02808c4 commit f379c58
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/slack/real_time/concurrency/celluloid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ def write(data)
end

def start_async(client)
Thread.new do
client.run_loop
end
@client = client
Actor.new(future.run_client_loop)
end

def run_client_loop
@client.run_loop
end

def connected?
Expand All @@ -79,6 +82,18 @@ def connected?

protected

class Actor
attr_reader :future

def initialize(future)
@future = future
end

def join
@future.value
end
end

def build_socket
socket = ::Celluloid::IO::TCPSocket.new(addr, port)
socket = ::Celluloid::IO::SSLSocket.new(socket, build_ssl_context) if secure?
Expand Down

0 comments on commit f379c58

Please sign in to comment.