added system.running for threads
This commit is contained in:
parent
a1cdd6e7ff
commit
7ad5cab17e
3 changed files with 14 additions and 10 deletions
|
|
@ -335,27 +335,22 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var TIntSet, pos: var int,
|
||||||
father: PNode, rectype: PSym)
|
father: PNode, rectype: PSym)
|
||||||
proc semRecordCase(c: PContext, n: PNode, check: var TIntSet, pos: var int,
|
proc semRecordCase(c: PContext, n: PNode, check: var TIntSet, pos: var int,
|
||||||
father: PNode, rectype: PSym) =
|
father: PNode, rectype: PSym) =
|
||||||
var
|
var a = copyNode(n)
|
||||||
covered: biggestint
|
|
||||||
chckCovered: bool
|
|
||||||
a, b: PNode
|
|
||||||
typ: PType
|
|
||||||
a = copyNode(n)
|
|
||||||
checkMinSonsLen(n, 2)
|
checkMinSonsLen(n, 2)
|
||||||
semRecordNodeAux(c, n.sons[0], check, pos, a, rectype)
|
semRecordNodeAux(c, n.sons[0], check, pos, a, rectype)
|
||||||
if a.sons[0].kind != nkSym:
|
if a.sons[0].kind != nkSym:
|
||||||
internalError("semRecordCase: dicriminant is no symbol")
|
internalError("semRecordCase: dicriminant is no symbol")
|
||||||
incl(a.sons[0].sym.flags, sfDiscriminant)
|
incl(a.sons[0].sym.flags, sfDiscriminant)
|
||||||
covered = 0
|
var covered: biggestInt = 0
|
||||||
typ = skipTypes(a.sons[0].Typ, abstractVar)
|
var typ = skipTypes(a.sons[0].Typ, abstractVar)
|
||||||
if not isOrdinalType(typ): GlobalError(n.info, errSelectorMustBeOrdinal)
|
if not isOrdinalType(typ): GlobalError(n.info, errSelectorMustBeOrdinal)
|
||||||
if firstOrd(typ) < 0:
|
if firstOrd(typ) < 0:
|
||||||
GlobalError(n.info, errOrdXMustNotBeNegative, a.sons[0].sym.name.s)
|
GlobalError(n.info, errOrdXMustNotBeNegative, a.sons[0].sym.name.s)
|
||||||
if lengthOrd(typ) > 0x00007FFF:
|
if lengthOrd(typ) > 0x00007FFF:
|
||||||
GlobalError(n.info, errLenXinvalid, a.sons[0].sym.name.s)
|
GlobalError(n.info, errLenXinvalid, a.sons[0].sym.name.s)
|
||||||
chckCovered = true
|
var chckCovered = true
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
b = copyTree(n.sons[i])
|
var b = copyTree(n.sons[i])
|
||||||
case n.sons[i].kind
|
case n.sons[i].kind
|
||||||
of nkOfBranch:
|
of nkOfBranch:
|
||||||
checkMinSonsLen(b, 2)
|
checkMinSonsLen(b, 2)
|
||||||
|
|
|
||||||
|
|
@ -290,6 +290,10 @@ template ThreadProcWrapperBody(closure: expr) =
|
||||||
# However this is doomed to fail, because we already unmapped every heap
|
# However this is doomed to fail, because we already unmapped every heap
|
||||||
# page!
|
# page!
|
||||||
|
|
||||||
|
# mark as not running anymore:
|
||||||
|
t.emptyFn = nil
|
||||||
|
t.dataFn = nil
|
||||||
|
|
||||||
{.push stack_trace:off.}
|
{.push stack_trace:off.}
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
proc threadProcWrapper[TMsg](closure: pointer): int32 {.stdcall.} =
|
proc threadProcWrapper[TMsg](closure: pointer): int32 {.stdcall.} =
|
||||||
|
|
@ -300,6 +304,10 @@ else:
|
||||||
ThreadProcWrapperBody(closure)
|
ThreadProcWrapperBody(closure)
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
|
proc running*[TMsg](t: TThread[TMsg]): bool {.inline.} =
|
||||||
|
## returns true if `t` is running.
|
||||||
|
result = t.emptyFn == nil and t.dataFn == nil
|
||||||
|
|
||||||
proc joinThread*[TMsg](t: TThread[TMsg]) {.inline.} =
|
proc joinThread*[TMsg](t: TThread[TMsg]) {.inline.} =
|
||||||
## waits for the thread `t` to finish.
|
## waits for the thread `t` to finish.
|
||||||
when hostOS == "windows":
|
when hostOS == "windows":
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ Library Additions
|
||||||
- Added ``matchers`` module for email address etc. matching.
|
- Added ``matchers`` module for email address etc. matching.
|
||||||
- Added ``strutils.unindent``.
|
- Added ``strutils.unindent``.
|
||||||
- Added ``system.slurp`` for easy resource embedding.
|
- Added ``system.slurp`` for easy resource embedding.
|
||||||
|
- Added ``system.running`` for threads.
|
||||||
|
|
||||||
|
|
||||||
2011-07-10 Version 0.8.12 released
|
2011-07-10 Version 0.8.12 released
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue