thread local vs. global system.raiseHook

This commit is contained in:
Araq
2011-10-23 01:12:24 +02:00
parent a757a08ab7
commit 2b323c638c
4 changed files with 22 additions and 8 deletions

View File

@@ -1447,11 +1447,20 @@ var
## set this variable to provide a procedure that should be called before
## each executed instruction. This should only be used by debuggers!
## Only code compiled with the ``debugger:on`` switch calls this hook.
raiseHook*: proc (e: ref E_Base): bool
globalRaiseHook*: proc (e: ref E_Base): bool
## with this hook you can influence exception handling on a global level.
## If not nil, every 'raise' statement ends up calling this hook. Ordinary
## application code should never set this hook! You better know what you
## do when setting this. If ``raiseHook`` returns false, the exception
## do when setting this. If ``globalRaiseHook`` returns false, the
## exception is caught and does not propagate further through the call
## stack.
localRaiseHook* {.threadvar.}: proc (e: ref E_Base): bool
## with this hook you can influence exception handling on a
## thread local level.
## If not nil, every 'raise' statement ends up calling this hook. Ordinary
## application code should never set this hook! You better know what you
## do when setting this. If ``localRaiseHook`` returns false, the exception
## is caught and does not propagate further through the call stack.
outOfMemHook*: proc

View File

@@ -194,8 +194,10 @@ proc quitOrDebug() {.inline.} =
proc raiseException(e: ref E_Base, ename: CString) {.compilerRtl.} =
e.name = ename
if raiseHook != nil:
if not raiseHook(e): return
if localRaiseHook != nil:
if not localRaiseHook(e): return
if globalRaiseHook != nil:
if not globalRaiseHook(e): return
if excHandler != nil:
pushCurrentException(e)
c_longjmp(excHandler.context, 1)

View File

@@ -6,11 +6,7 @@ Version 0.8.14
- fix actors.nim
- make threadvar efficient again on linux after testing
- test the sort implementation again
- optional indentation for 'case' statement
- document & test splicing; don't forget to test negative indexes
- thread local vs. global raiseHook()
- make pegs support a compile-time option and make c2nim use regexes instead
per default
- implement lib/pure/memfiles properly
incremental compilation
@@ -32,6 +28,7 @@ version 0.9.0
- const ptr/ref
- unsigned ints and bignums
- implement the high level optimizer
- warning for implicit openArray -> varargs convention
- implement explicit varargs
- tests: run the GC tests
@@ -43,6 +40,7 @@ version 0.9.0
- os module should use Windows Unicode versions
- 64bit build for Windows
- codegen should use "NIM_CAST" macro and respect aliasing rules for GCC
- optional indentation for 'case' statement
Bugs
----
@@ -74,6 +72,8 @@ version 0.9.XX
- 'nimrod def': does not always work?
- test branch coverage
- checked exceptions
- make pegs support a compile-time option and make c2nim use regexes instead
per default?
- fix implicit generic routines
- think about ``{:}.toTable[int, string]()``
- mocking support with ``tyProxy`` that does:

View File

@@ -39,6 +39,9 @@ Changes affecting backwards compatibility
- The threading API has been completely redesigned.
- The ``unidecode`` module is now thread-safe and its interface has changed.
- The ``bind`` expression is deprecated, use a ``bind`` declaration instead.
- ``system.raiseHook`` is now split into ``system.localRaiseHook`` and
``system.globalRaiseHook`` to distinguish between thread local and global
raise hooks.
Language Additions