Merge branch 'devel' of https://github.com/Araq/Nimrod into devel
This commit is contained in:
commit
e5fd84c559
2 changed files with 38 additions and 11 deletions
|
|
@ -180,6 +180,27 @@ proc asyncCheck*[T](future: PFuture[T]) =
|
||||||
echoOriginalStackTrace(future)
|
echoOriginalStackTrace(future)
|
||||||
raise future.error
|
raise future.error
|
||||||
|
|
||||||
|
proc `and`*[T, Y](fut1: PFuture[T], fut2: PFuture[Y]): PFuture[void] =
|
||||||
|
## Returns a future which will complete once both ``fut1`` and ``fut2``
|
||||||
|
## complete.
|
||||||
|
var retFuture = newFuture[void]()
|
||||||
|
fut1.callback =
|
||||||
|
proc () =
|
||||||
|
if fut2.finished: retFuture.complete()
|
||||||
|
fut2.callback =
|
||||||
|
proc () =
|
||||||
|
if fut1.finished: retFuture.complete()
|
||||||
|
return retFuture
|
||||||
|
|
||||||
|
proc `or`*[T, Y](fut1: PFuture[T], fut2: PFuture[Y]): PFuture[void] =
|
||||||
|
## Returns a future which will complete once either ``fut1`` or ``fut2``
|
||||||
|
## complete.
|
||||||
|
var retFuture = newFuture[void]()
|
||||||
|
proc cb() =
|
||||||
|
if not retFuture.finished: retFuture.complete()
|
||||||
|
fut1.callback = cb
|
||||||
|
fut2.callback = cb
|
||||||
|
|
||||||
type
|
type
|
||||||
PDispatcherBase = ref object of PObject
|
PDispatcherBase = ref object of PObject
|
||||||
timers: seq[tuple[finishAt: float, fut: PFuture[void]]]
|
timers: seq[tuple[finishAt: float, fut: PFuture[void]]]
|
||||||
|
|
|
||||||
|
|
@ -114,63 +114,69 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
proc addInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
proc addInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
# a in eax, and b in edx
|
# a in eax, and b in edx
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, ecx
|
||||||
add eax, `b`
|
add eax, edx
|
||||||
jno theEnd
|
jno theEnd
|
||||||
call `raiseOverflow`
|
call `raiseOverflow`
|
||||||
theEnd:
|
theEnd:
|
||||||
|
ret
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc subInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
proc subInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, ecx
|
||||||
sub eax, `b`
|
sub eax, edx
|
||||||
jno theEnd
|
jno theEnd
|
||||||
call `raiseOverflow`
|
call `raiseOverflow`
|
||||||
theEnd:
|
theEnd:
|
||||||
|
ret
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc negInt(a: int): int {.compilerProc, asmNoStackFrame.} =
|
proc negInt(a: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, ecx
|
||||||
neg eax
|
neg eax
|
||||||
jno theEnd
|
jno theEnd
|
||||||
call `raiseOverflow`
|
call `raiseOverflow`
|
||||||
theEnd:
|
theEnd:
|
||||||
|
ret
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc divInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
proc divInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, ecx
|
||||||
mov ecx, `b`
|
mov ecx, edx
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
idiv ecx
|
idiv ecx
|
||||||
jno theEnd
|
jno theEnd
|
||||||
call `raiseOverflow`
|
call `raiseOverflow`
|
||||||
theEnd:
|
theEnd:
|
||||||
|
ret
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc modInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
proc modInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, ecx
|
||||||
mov ecx, `b`
|
mov ecx, edx
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
idiv ecx
|
idiv ecx
|
||||||
jno theEnd
|
jno theEnd
|
||||||
call `raiseOverflow`
|
call `raiseOverflow`
|
||||||
theEnd:
|
theEnd:
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
|
ret
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc mulInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
proc mulInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, ecx
|
||||||
mov ecx, `b`
|
mov ecx, edx
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
imul ecx
|
imul ecx
|
||||||
jno theEnd
|
jno theEnd
|
||||||
call `raiseOverflow`
|
call `raiseOverflow`
|
||||||
theEnd:
|
theEnd:
|
||||||
|
ret
|
||||||
"""
|
"""
|
||||||
|
|
||||||
elif false: # asmVersion and (defined(gcc) or defined(llvm_gcc)):
|
elif false: # asmVersion and (defined(gcc) or defined(llvm_gcc)):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue