Skip to content

Commit

Permalink
Apply suggestions: Refactor code shape
Browse files Browse the repository at this point in the history
Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>

Co-authored-by: Takuro Ashie <ashie@clear-code.com>
  • Loading branch information
daipom and ashie committed Mar 7, 2023
1 parent ce32ac5 commit bebc6db
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -619,22 +619,18 @@ def lock_if_need(worker_lock_name)

def get_worker_lock_if_need(name)
need_worker_lock = system_config.workers > 1
unless need_worker_lock
yield
return
end
acquire_worker_lock(name) do
if need_worker_lock
acquire_worker_lock(name) { yield }
else
yield
end
end

def get_flush_thread_lock_if_need
need_thread_lock = actual_flush_thread_count > 1
unless need_thread_lock
yield
return
end
@flush_thread_mutex.synchronize do
if need_thread_lock
@flush_thread_mutex.synchronize { yeild }
else
yield
end
end
Expand Down

0 comments on commit bebc6db

Please sign in to comment.