Aller au contenu

Leaked Concurrency Handle (ARCH6085)

Ce contenu n’est pas encore disponible dans votre langue.

Key ruby.performance.leaked-concurrency-handle · Severity warning · Category performance

A lock acquired with lock and held without the block form is never released if an exception is raised, causing a deadlock. Manage the lock with the block form.

def increment(mutex, counter)
mutex.lock
counter.value += 1
mutex.unlock
end
def increment(mutex, counter)
mutex.synchronize do
counter.value += 1
end
end

Acquire locks with the synchronize block form; start threads with a bounded lifetime and join them.