Merge branch 'devel' of github.com:nim-lang/Nim into devel
This commit is contained in:
commit
e8a52a0fc2
5 changed files with 37 additions and 9 deletions
|
|
@ -84,10 +84,10 @@ proc mapTypeToAstX(t: PType; info: TLineInfo;
|
||||||
|
|
||||||
if inst:
|
if inst:
|
||||||
if t.sym != nil: # if this node has a symbol
|
if t.sym != nil: # if this node has a symbol
|
||||||
if allowRecursion: # getTypeImpl behavior: turn off recursion
|
if not allowRecursion: # getTypeInst behavior: return symbol
|
||||||
allowRecursion = false
|
|
||||||
else: # getTypeInst behavior: return symbol
|
|
||||||
return atomicType(t.sym)
|
return atomicType(t.sym)
|
||||||
|
#else: # getTypeImpl behavior: turn off recursion
|
||||||
|
# allowRecursion = false
|
||||||
|
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyNone: result = atomicType("none", mNone)
|
of tyNone: result = atomicType("none", mNone)
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,10 @@ export asyncfutures, asyncstreams
|
||||||
##
|
##
|
||||||
## .. code-block::nim
|
## .. code-block::nim
|
||||||
## var future = socket.recv(100)
|
## var future = socket.recv(100)
|
||||||
## future.callback =
|
## future.addCallback(
|
||||||
## proc () =
|
## proc () =
|
||||||
## echo(future.read)
|
## echo(future.read)
|
||||||
|
## )
|
||||||
##
|
##
|
||||||
## All asynchronous functions returning a ``Future`` will not block. They
|
## All asynchronous functions returning a ``Future`` will not block. They
|
||||||
## will not however return immediately. An asynchronous function will have
|
## will not however return immediately. An asynchronous function will have
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,7 @@ proc all*[T](futs: varargs[Future[T]]): auto =
|
||||||
let totalFutures = len(futs)
|
let totalFutures = len(futs)
|
||||||
|
|
||||||
for fut in futs:
|
for fut in futs:
|
||||||
fut.callback = proc(f: Future[T]) =
|
fut.addCallback proc (f: Future[T]) =
|
||||||
inc(completedFutures)
|
inc(completedFutures)
|
||||||
if not retFuture.finished:
|
if not retFuture.finished:
|
||||||
if f.failed:
|
if f.failed:
|
||||||
|
|
@ -355,7 +355,7 @@ proc all*[T](futs: varargs[Future[T]]): auto =
|
||||||
|
|
||||||
for i, fut in futs:
|
for i, fut in futs:
|
||||||
proc setCallback(i: int) =
|
proc setCallback(i: int) =
|
||||||
fut.callback = proc(f: Future[T]) =
|
fut.addCallback proc (f: Future[T]) =
|
||||||
inc(completedFutures)
|
inc(completedFutures)
|
||||||
if not retFuture.finished:
|
if not retFuture.finished:
|
||||||
if f.failed:
|
if f.failed:
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,16 @@ proc testVarargs(x, y, z: int): seq[int] =
|
||||||
|
|
||||||
result = waitFor all(a, b, c)
|
result = waitFor all(a, b, c)
|
||||||
|
|
||||||
|
proc testWithDupes() =
|
||||||
|
var
|
||||||
|
tasks = newSeq[Future[void]](taskCount)
|
||||||
|
fut = futureWithoutValue()
|
||||||
|
|
||||||
|
for i in 0..<taskCount:
|
||||||
|
tasks[i] = fut
|
||||||
|
|
||||||
|
waitFor all(tasks)
|
||||||
|
|
||||||
block:
|
block:
|
||||||
let
|
let
|
||||||
startTime = cpuTime()
|
startTime = cpuTime()
|
||||||
|
|
@ -57,6 +67,13 @@ block:
|
||||||
|
|
||||||
doAssert execTime * 1000 < taskCount * sleepDuration
|
doAssert execTime * 1000 < taskCount * sleepDuration
|
||||||
|
|
||||||
|
block:
|
||||||
|
let startTime = cpuTime()
|
||||||
|
testWithDupes()
|
||||||
|
let execTime = cpuTime() - startTime
|
||||||
|
|
||||||
|
doAssert execTime * 1000 < taskCount * sleepDuration
|
||||||
|
|
||||||
block:
|
block:
|
||||||
let
|
let
|
||||||
startTime = cpuTime()
|
startTime = cpuTime()
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,12 @@ type
|
||||||
Generic[T] = seq[int]
|
Generic[T] = seq[int]
|
||||||
Concrete = Generic[int]
|
Concrete = Generic[int]
|
||||||
|
|
||||||
|
Generic2[T1, T2] = seq[T1]
|
||||||
|
Concrete2 = Generic2[int, float]
|
||||||
|
|
||||||
Alias1 = float
|
Alias1 = float
|
||||||
Alias2 = Concrete
|
Alias2 = Concrete
|
||||||
|
Alias3 = Concrete2
|
||||||
|
|
||||||
Vec[N: static[int],T] = object
|
Vec[N: static[int],T] = object
|
||||||
arr: array[N,T]
|
arr: array[N,T]
|
||||||
|
|
@ -154,15 +158,21 @@ test(Tree):
|
||||||
left: ref Tree
|
left: ref Tree
|
||||||
right: ref Tree
|
right: ref Tree
|
||||||
test(Concrete):
|
test(Concrete):
|
||||||
type _ = Generic[int]
|
type _ = seq[int]
|
||||||
test(Generic[int]):
|
test(Generic[int]):
|
||||||
type _ = seq[int]
|
type _ = seq[int]
|
||||||
test(Generic[float]):
|
test(Generic[float]):
|
||||||
type _ = seq[int]
|
type _ = seq[int]
|
||||||
|
test(Concrete2):
|
||||||
|
type _ = seq[int]
|
||||||
|
test(Generic2[int,float]):
|
||||||
|
type _ = seq[int]
|
||||||
test(Alias1):
|
test(Alias1):
|
||||||
type _ = float
|
type _ = float
|
||||||
test(Alias2):
|
test(Alias2):
|
||||||
type _ = Generic[int]
|
type _ = seq[int]
|
||||||
|
test(Alias3):
|
||||||
|
type _ = seq[int]
|
||||||
test(Vec[4,float32]):
|
test(Vec[4,float32]):
|
||||||
type _ = object
|
type _ = object
|
||||||
arr: array[0..3,float32]
|
arr: array[0..3,float32]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue