Skip to content

Commit

Permalink
Changed dependency to NSLock and use DispatchQueue instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
jollyjinx committed Mar 22, 2024
1 parent fb1f253 commit 3cfc2f6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/modbus2mqtt/ModbusDefinition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ extension ModbusDefinition

private final class ModbusDefinitionStore : @unchecked Sendable
{
private let lock = NSLock()
let userMutatingLock = DispatchQueue(label: "definitions.lock.queue." + UUID().uuidString)
private var _modbusDefinitions: [Int: ModbusDefinition] = [:]

var definitions: [Int: ModbusDefinition]
{
get { lock.lock(); defer { lock.unlock() }; return _modbusDefinitions }
set { lock.lock(); defer { lock.unlock() };_modbusDefinitions = newValue }
get { userMutatingLock.sync { _modbusDefinitions } }
set { userMutatingLock.sync { _modbusDefinitions = newValue } }
}

init()
Expand Down

0 comments on commit 3cfc2f6

Please sign in to comment.