mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-02-20 23:18:22 +00:00
assert() -> doAssert()
This commit is contained in:
parent
79376dab20
commit
685665ad21
@ -143,18 +143,18 @@ proc remove(callbacks: var Deque[AsyncCallback], item: AsyncCallback) =
|
||||
|
||||
proc complete*[T](future: Future[T], val: T) =
|
||||
## Completes ``future`` with value ``val``.
|
||||
#assert(not future.finished, "Future already finished, cannot finish twice.")
|
||||
#doAssert(not future.finished, "Future already finished, cannot finish twice.")
|
||||
checkFinished(future)
|
||||
assert(future.error == nil)
|
||||
doAssert(future.error == nil)
|
||||
future.value = val
|
||||
future.finished = true
|
||||
future.callbacks.call()
|
||||
|
||||
proc complete*(future: Future[void]) =
|
||||
## Completes a void ``future``.
|
||||
#assert(not future.finished, "Future already finished, cannot finish twice.")
|
||||
#doAssert(not future.finished, "Future already finished, cannot finish twice.")
|
||||
checkFinished(future)
|
||||
assert(future.error == nil)
|
||||
doAssert(future.error == nil)
|
||||
future.finished = true
|
||||
future.callbacks.call()
|
||||
|
||||
@ -162,7 +162,7 @@ proc complete*[T](future: FutureVar[T]) =
|
||||
## Completes a ``FutureVar``.
|
||||
template fut: untyped = Future[T](future)
|
||||
checkFinished(fut)
|
||||
assert(fut.error == nil)
|
||||
doAssert(fut.error == nil)
|
||||
fut.finished = true
|
||||
fut.callbacks.call()
|
||||
|
||||
@ -172,14 +172,14 @@ proc complete*[T](future: FutureVar[T], val: T) =
|
||||
## Any previously stored value will be overwritten.
|
||||
template fut: untyped = Future[T](future)
|
||||
checkFinished(fut)
|
||||
assert(fut.error.isNil())
|
||||
doAssert(fut.error.isNil())
|
||||
fut.finished = true
|
||||
fut.value = val
|
||||
fut.callbacks.call()
|
||||
|
||||
proc fail*[T](future: Future[T], error: ref Exception) =
|
||||
## Completes ``future`` with ``error``.
|
||||
#assert(not future.finished, "Future already finished, cannot finish twice.")
|
||||
#doAssert(not future.finished, "Future already finished, cannot finish twice.")
|
||||
checkFinished(future)
|
||||
future.finished = true
|
||||
future.error = error
|
||||
@ -198,7 +198,7 @@ proc addCallback*(future: FutureBase, cb: CallbackFunc, udata: pointer = nil) =
|
||||
## Adds the callbacks proc to be called when the future completes.
|
||||
##
|
||||
## If future has already completed then ``cb`` will be called immediately.
|
||||
assert cb != nil
|
||||
doAssert cb != nil
|
||||
if future.finished:
|
||||
# ZAH: it seems that the Future needs to know its associated Dispatcher
|
||||
callSoon(cb, udata)
|
||||
@ -214,7 +214,7 @@ proc addCallback*[T](future: Future[T], cb: CallbackFunc) =
|
||||
|
||||
proc removeCallback*(future: FutureBase, cb: CallbackFunc,
|
||||
udata: pointer = nil) =
|
||||
assert cb != nil
|
||||
doAssert cb != nil
|
||||
let acb = AsyncCallback(function: cb, udata: udata)
|
||||
future.callbacks.remove acb
|
||||
|
||||
@ -363,7 +363,7 @@ proc asyncCheck*[T](future: Future[T]) =
|
||||
## finished with an error.
|
||||
##
|
||||
## This should be used instead of ``discard`` to discard void futures.
|
||||
assert(not future.isNil, "Future is nil")
|
||||
doAssert(not future.isNil, "Future is nil")
|
||||
proc cb(data: pointer) =
|
||||
if future.failed:
|
||||
injectStacktrace(future)
|
||||
|
@ -290,7 +290,7 @@ when defined(windows) or defined(nimdoc):
|
||||
proc setGlobalDispatcher*(disp: PDispatcher) =
|
||||
## Set current thread's dispatcher instance to ``disp``.
|
||||
if not gDisp.isNil:
|
||||
assert gDisp.callbacks.len == 0
|
||||
doAssert gDisp.callbacks.len == 0
|
||||
gDisp = disp
|
||||
initCallSoonProc()
|
||||
|
||||
@ -465,7 +465,7 @@ else:
|
||||
proc setGlobalDispatcher*(disp: PDispatcher) =
|
||||
## Set current thread's dispatcher instance to ``disp``.
|
||||
if not gDisp.isNil:
|
||||
assert gDisp.callbacks.len == 0
|
||||
doAssert gDisp.callbacks.len == 0
|
||||
gDisp = disp
|
||||
initCallSoonProc()
|
||||
|
||||
@ -746,7 +746,7 @@ include asyncmacro2
|
||||
proc callSoon(cbproc: CallbackFunc, data: pointer = nil) =
|
||||
## Schedule `cbproc` to be called as soon as possible.
|
||||
## The callback is called when control returns to the event loop.
|
||||
assert cbproc != nil
|
||||
doAssert cbproc != nil
|
||||
let acb = AsyncCallback(function: cbproc, udata: data)
|
||||
getGlobalDispatcher().callbacks.addLast(acb)
|
||||
|
||||
|
@ -421,7 +421,7 @@ proc resolveTAddress*(address: string, port: Port,
|
||||
##
|
||||
## If hostname address is detected, then network address translation via DNS
|
||||
## will be performed.
|
||||
assert(family in {AddressFamily.IPv4, AddressFamily.IPv6})
|
||||
doAssert(family in {AddressFamily.IPv4, AddressFamily.IPv6})
|
||||
|
||||
result = newSeq[TransportAddress]()
|
||||
var domain = if family == AddressFamily.IPv4: Domain.AF_INET else:
|
||||
|
@ -198,9 +198,9 @@ when defined(windows):
|
||||
child: DatagramTransport,
|
||||
bufferSize: int): DatagramTransport =
|
||||
var localSock: AsyncFD
|
||||
assert(remote.family == local.family)
|
||||
assert(not isNil(cbproc))
|
||||
assert(remote.family in {AddressFamily.IPv4, AddressFamily.IPv6})
|
||||
doAssert(remote.family == local.family)
|
||||
doAssert(not isNil(cbproc))
|
||||
doAssert(remote.family in {AddressFamily.IPv4, AddressFamily.IPv6})
|
||||
|
||||
if isNil(child):
|
||||
result = DatagramTransport()
|
||||
@ -376,8 +376,8 @@ else:
|
||||
child: DatagramTransport = nil,
|
||||
bufferSize: int): DatagramTransport =
|
||||
var localSock: AsyncFD
|
||||
assert(remote.family == local.family)
|
||||
assert(not isNil(cbproc))
|
||||
doAssert(remote.family == local.family)
|
||||
doAssert(not isNil(cbproc))
|
||||
|
||||
if isNil(child):
|
||||
result = DatagramTransport()
|
||||
|
@ -148,7 +148,7 @@ proc swarmWorker1(address: TransportAddress): Future[int] {.async.} =
|
||||
for i in 0..<MessagesCount:
|
||||
var data = "REQUEST" & $i & "\r\n"
|
||||
var res = await transp.write(cast[pointer](addr data[0]), len(data))
|
||||
assert(res == len(data))
|
||||
doAssert(res == len(data))
|
||||
var ans = await transp.readLine()
|
||||
doAssert(ans.startsWith("ANSWER"))
|
||||
var numstr = ans[6..^1]
|
||||
|
Loading…
x
Reference in New Issue
Block a user