From 8a2f481f9993dcfbc8e682710782ff2fe6725da4 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 12 Oct 2017 12:45:18 +0200 Subject: make threadpool care about minPoolSize --- lib/pure/concurrency/threadpool.nim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/pure/concurrency') diff --git a/lib/pure/concurrency/threadpool.nim b/lib/pure/concurrency/threadpool.nim index 2a0dbd2ca..0f23b7e85 100644 --- a/lib/pure/concurrency/threadpool.nim +++ b/lib/pure/concurrency/threadpool.nim @@ -448,12 +448,22 @@ proc nimSpawn3(fn: WorkerProc; data: pointer) {.compilerProc.} = if selectWorker(readyWorker, fn, data): return for i in 0.. Date: Wed, 25 Oct 2017 17:19:40 +0300 Subject: [Windows] Use GetSystemInfo for obtaining processor count (#6082) --- lib/pure/concurrency/cpuinfo.nim | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'lib/pure/concurrency') diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim index 603fee080..66ebd155c 100644 --- a/lib/pure/concurrency/cpuinfo.nim +++ b/lib/pure/concurrency/cpuinfo.nim @@ -45,8 +45,31 @@ proc countProcessors*(): int {.rtl, extern: "ncpi$1".} = ## returns the numer of the processors/cores the machine has. ## Returns 0 if it cannot be detected. when defined(windows): - var x = getEnv("NUMBER_OF_PROCESSORS") - if x.len > 0: result = parseInt(x.string) + type + SYSTEM_INFO_UNION1_STRUCT1 {.final, pure.} = object + wProcessorArchitecture: int16 + wReserved: int16 + SYSTEM_INFO_UNION1 {.final, union, pure.} = object + dwOemId: int32 + s1: SYSTEM_INFO_UNION1_STRUCT1 + SYSTEM_INFO {.final, pure.} = object + u1: SYSTEM_INFO_UNION1 + dwPageSize: int32 + lpMinimumApplicationAddress: pointer + lpMaximumApplicationAddress: pointer + dwActiveProcessorMask: int32 + dwNumberOfProcessors: int32 + dwProcessorType: int32 + dwAllocationGranularity: int32 + wProcessorLevel: int16 + wProcessorRevision: int16 + + proc GetSystemInfo(lpSystemInfo: var SYSTEM_INFO) {.stdcall, dynlib: "kernel32", importc: "GetSystemInfo".} + + var + si: SYSTEM_INFO + GetSystemInfo(si) + result = si.dwNumberOfProcessors elif defined(macosx) or defined(bsd): var mib: array[0..3, cint] -- cgit 1.4.1-2-gfad0 From 928bdb45f09fc2b8f9f1ca3624a815b9d92f314b Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 26 Oct 2017 00:53:23 +0200 Subject: fixes cpuinfo regression --- lib/pure/concurrency/cpuinfo.nim | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'lib/pure/concurrency') diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim index 66ebd155c..f01488811 100644 --- a/lib/pure/concurrency/cpuinfo.nim +++ b/lib/pure/concurrency/cpuinfo.nim @@ -46,18 +46,12 @@ proc countProcessors*(): int {.rtl, extern: "ncpi$1".} = ## Returns 0 if it cannot be detected. when defined(windows): type - SYSTEM_INFO_UNION1_STRUCT1 {.final, pure.} = object - wProcessorArchitecture: int16 - wReserved: int16 - SYSTEM_INFO_UNION1 {.final, union, pure.} = object - dwOemId: int32 - s1: SYSTEM_INFO_UNION1_STRUCT1 SYSTEM_INFO {.final, pure.} = object - u1: SYSTEM_INFO_UNION1 + u1: int32 dwPageSize: int32 lpMinimumApplicationAddress: pointer lpMaximumApplicationAddress: pointer - dwActiveProcessorMask: int32 + dwActiveProcessorMask: ptr int32 dwNumberOfProcessors: int32 dwProcessorType: int32 dwAllocationGranularity: int32 -- cgit 1.4.1-2-gfad0 From 6a3288a60e78c9b17f2640fff20ab94969914974 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 29 Oct 2017 08:55:30 +0100 Subject: more replacements for the deprecated '<' --- lib/core/macros.nim | 6 +++--- lib/deprecated/pure/actors.nim | 6 +++--- lib/pure/collections/critbits.nim | 2 +- lib/pure/collections/tableimpl.nim | 2 +- lib/pure/concurrency/threadpool.nim | 4 ++-- lib/pure/future.nim | 6 +++--- lib/pure/json.nim | 16 ++++++++-------- lib/pure/marshal.nim | 2 +- lib/pure/selectors.nim | 4 ++-- lib/pure/strutils.nim | 6 +++--- lib/pure/uri.nim | 2 +- lib/system/debugger.nim | 2 +- lib/system/gc.nim | 6 +++--- lib/system/gc2.nim | 6 +++--- lib/system/gc_ms.nim | 4 ++-- lib/system/repr.nim | 2 +- lib/system/reprjs.nim | 6 +++--- lib/system/sysstr.nim | 2 +- lib/wrappers/openssl.nim | 2 +- 19 files changed, 43 insertions(+), 43 deletions(-) (limited to 'lib/pure/concurrency') diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 22c479a4a..d3f541153 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -839,7 +839,7 @@ proc newNilLit*(): NimNode {.compileTime.} = ## New nil literal shortcut result = newNimNode(nnkNilLit) -proc last*(node: NimNode): NimNode {.compileTime.} = node[`*(p, b: untyped): untyped = if c[0].kind == nnkIdent and c[0].ident == !"->": var procTy = createProcType(c[1], c[2]) params[0] = procTy[0][0] - for i in 1 .. ) got (" & $c[0].ident & ").") @@ -96,7 +96,7 @@ macro `=>`*(p, b: untyped): untyped = if p[0].kind == nnkIdent and p[0].ident == !"->": var procTy = createProcType(p[1], p[2]) params[0] = procTy[0][0] - for i in 1 .. ) got (" & $p[0].ident & ").") diff --git a/lib/pure/json.nim b/lib/pure/json.nim index fd7a3af03..3d86cc9d7 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -823,13 +823,13 @@ proc toJson(x: NimNode): NimNode {.compiletime.} = of nnkBracket: # array if x.len == 0: return newCall(bindSym"newJArray") result = newNimNode(nnkBracket) - for i in 0 .. s.len: return -1 - + if sub.len == 1: return find(s, sub[0], start, last) - + var a {.noinit.}: SkipTable initSkipTable(a, sub) result = find(a, s, sub, start, last) diff --git a/lib/pure/uri.nim b/lib/pure/uri.nim index 4b2e4e052..c702b054c 100644 --- a/lib/pure/uri.nim +++ b/lib/pure/uri.nim @@ -250,7 +250,7 @@ proc combine*(base: Uri, reference: Uri): Uri = proc combine*(uris: varargs[Uri]): Uri = ## Combines multiple URIs together. result = uris[0] - for i in 1 .. 0 : add(result, ", ") # advance pointer and point to element at index @@ -192,7 +192,7 @@ proc reprRecordAux(result: var string, o: pointer, typ: PNimType, cl: var ReprCl reprAux(result, val, typ.node.typ, cl) else: # if the object has more than one field, sons is not nil and contains the fields. - for i in 0 .. Date: Sun, 29 Oct 2017 23:09:46 +0100 Subject: make tests green again --- lib/deprecated/pure/actors.nim | 4 ++-- lib/pure/collections/deques.nim | 4 ++-- lib/pure/concurrency/threadpool.nim | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/pure/concurrency') diff --git a/lib/deprecated/pure/actors.nim b/lib/deprecated/pure/actors.nim index be01fb3f6..17321cc0e 100644 --- a/lib/deprecated/pure/actors.nim +++ b/lib/deprecated/pure/actors.nim @@ -164,8 +164,8 @@ proc terminate*[In, Out](a: var ActorPool[In, Out]) = ## resources attached to `a`. var t: Task[In, Out] t.shutdown = true - for i in 0.. = 0 diff --git a/lib/pure/concurrency/threadpool.nim b/lib/pure/concurrency/threadpool.nim index 01dcad9f9..a5eaec86e 100644 --- a/lib/pure/concurrency/threadpool.nim +++ b/lib/pure/concurrency/threadpool.nim @@ -401,7 +401,7 @@ proc setup() = gCpus = p currentPoolSize = min(p, MaxThreadPoolSize) readyWorker = addr(workersData[0]) - for i in 0..