remove unnecesary async lock
This commit is contained in:
parent
934c858542
commit
f767614827
|
@ -33,7 +33,6 @@ type
|
||||||
msgCode*: MessageType
|
msgCode*: MessageType
|
||||||
closeCode*: MessageType
|
closeCode*: MessageType
|
||||||
resetCode*: MessageType
|
resetCode*: MessageType
|
||||||
asyncLock: AsyncLock
|
|
||||||
|
|
||||||
proc newChannel*(id: uint,
|
proc newChannel*(id: uint,
|
||||||
conn: Connection,
|
conn: Connection,
|
||||||
|
@ -49,19 +48,16 @@ proc newChannel*(id: uint,
|
||||||
result.msgCode = if initiator: MessageType.MsgOut else: MessageType.MsgIn
|
result.msgCode = if initiator: MessageType.MsgOut else: MessageType.MsgIn
|
||||||
result.closeCode = if initiator: MessageType.CloseOut else: MessageType.CloseIn
|
result.closeCode = if initiator: MessageType.CloseOut else: MessageType.CloseIn
|
||||||
result.resetCode = if initiator: MessageType.ResetOut else: MessageType.ResetIn
|
result.resetCode = if initiator: MessageType.ResetOut else: MessageType.ResetIn
|
||||||
result.asyncLock = newAsyncLock()
|
|
||||||
result.isLazy = lazy
|
result.isLazy = lazy
|
||||||
|
|
||||||
let chan = result
|
let chan = result
|
||||||
proc writeHandler(data: seq[byte]): Future[void] {.async.} =
|
proc writeHandler(data: seq[byte]): Future[void] {.async.} =
|
||||||
# writes should happen in sequence
|
# writes should happen in sequence
|
||||||
await chan.asyncLock.acquire()
|
|
||||||
trace "sending data ", data = data.toHex(),
|
trace "sending data ", data = data.toHex(),
|
||||||
id = chan.id,
|
id = chan.id,
|
||||||
initiator = chan.initiator
|
initiator = chan.initiator
|
||||||
|
|
||||||
await conn.writeMsg(chan.id, chan.msgCode, data) # write header
|
await conn.writeMsg(chan.id, chan.msgCode, data) # write header
|
||||||
chan.asyncLock.release()
|
|
||||||
|
|
||||||
result.initBufferStream(writeHandler, size)
|
result.initBufferStream(writeHandler, size)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue