Skip to content

Commit

Permalink
Add manual reporting of changes to the Darwin adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Maher4Ever committed Jul 24, 2012
1 parent b1e2607 commit 38eec03
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/listen/adapters/darwin.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ def start(blocking = true)
end end


@worker_thread = Thread.new { @worker.run } @worker_thread = Thread.new { @worker.run }
@poll_thread = Thread.new { poll_changed_dirs }


# The FSEvent worker needs sometime to startup. Turnstiles can't # The FSEvent worker needs sometime to startup. Turnstiles can't
# be used to wait for it as it runs in a loop. # be used to wait for it as it runs in a loop.
# TODO: Find a better way to block until the worker starts. # TODO: Find a better way to block until the worker starts.
sleep @latency sleep 0.1
@poll_thread.join if blocking
@poll_thread = Thread.new { poll_changed_dirs } if @report_changes
@worker_thread.join if blocking
end end


# Stops the adapter. # Stops the adapter.
Expand All @@ -43,8 +44,8 @@ def stop
end end


@worker.stop @worker.stop
Thread.kill(@worker_thread) if @worker_thread @worker_thread.join if @worker_thread
@poll_thread.join @poll_thread.join if @poll_thread
end end


# Checks if the adapter is usable on the current OS. # Checks if the adapter is usable on the current OS.
Expand Down

0 comments on commit 38eec03

Please sign in to comment.