Skip to content

Commit

Permalink
issue #481: restore previous public behavior: exception name (NotStar…
Browse files Browse the repository at this point in the history
…ted), and silently no-op on start if already started
  • Loading branch information
ColinDKelley authored and ioquatix committed Sep 16, 2020
1 parent af7e37e commit 3dff536
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/listen/event/loop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class Loop
include Listen::FSM

class Error < RuntimeError
class ThreadFailedToStart < Error; end
class AlreadyStarted < Error; end
class NotStarted < Error; end
end

start_state :pre_start
Expand Down Expand Up @@ -40,17 +39,18 @@ def started?

def start
# TODO: use a Fiber instead?
transition! :starting do
state == :pre_start or raise Error::AlreadyStarted
end
return unless state == :pre_start

transition! :starting

@wait_thread = Thread.new do
_process_changes
end

Listen::Logger.debug("Waiting for processing to start...")

wait_for_state(:started, MAX_STARTUP_SECONDS) or raise Error::ThreadFailedToStart, "thread didn't start in #{MAX_STARTUP_SECONDS} seconds (in state: #{state.inspect})"
wait_for_state(:started, MAX_STARTUP_SECONDS) or
raise Error::NotStarted, "thread didn't start in #{MAX_STARTUP_SECONDS} seconds (in state: #{state.inspect})"

Listen::Logger.debug('Processing started.')
end
Expand Down

0 comments on commit 3dff536

Please sign in to comment.