A module that will allow your program to be multi-threaded,
micro-threaded, and single-threaded. Currently microthreads are
unimplemented. The idea is to abstract away some commonly used
functionality so that I don't have to special-case it in all programs.
Imported modules
|
|
import hook
import log
import sys
import traceback
|
Functions
|
|
_synchPost
_synchPre
init
isInIOThread
registerAsIOThread
synchronize
whenThreaded
|
|
_synchPost
|
_synchPost (
self,
*a,
*b,
)
|
|
_synchPre
|
_synchPre (
self,
*a,
*b,
)
|
|
init
|
init ( with_threads=1 )
Initialize threading. Should be run once, at the beginning of program.
Exceptions
|
|
RuntimeError( "threads cannot be disabled, once enabled" )
|
|
|
isInIOThread
|
isInIOThread ()
Are we in the thread responsable for I/O requests (the event loop)?
|
|
registerAsIOThread
|
registerAsIOThread ()
Mark the current thread as responsable for I/O requests.
|
|
synchronize
|
synchronize ( *klasses )
Make all methods listed in each class' synchronized attribute synchronized.
The synchronized attribute should be a list of strings, consisting of the
names of methods that must be synchronized. If we are running in threaded
mode these methods will be wrapped with a lock.
|
|
whenThreaded
|
whenThreaded ( cb )
|
Classes
|
|
|
|