diff options
author | Josh Blum | 2013-03-17 17:38:40 -0700 |
---|---|---|
committer | Josh Blum | 2013-03-17 17:38:40 -0700 |
commit | 468d53f7797c63cda2ef9ba765f1066550d19ce4 (patch) | |
tree | 4008d74ee3138114799e9bf8434f8356e8ad804f /python/gras/GRAS_Utils.i | |
parent | 420f118ed61c52ae00b765b57be83bae910e0a60 (diff) | |
download | sandhi-468d53f7797c63cda2ef9ba765f1066550d19ce4.tar.gz sandhi-468d53f7797c63cda2ef9ba765f1066550d19ce4.tar.bz2 sandhi-468d53f7797c63cda2ef9ba765f1066550d19ce4.zip |
gras: work on python hooks for props interface
Diffstat (limited to 'python/gras/GRAS_Utils.i')
-rw-r--r-- | python/gras/GRAS_Utils.i | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/python/gras/GRAS_Utils.i b/python/gras/GRAS_Utils.i new file mode 100644 index 0000000..afe3314 --- /dev/null +++ b/python/gras/GRAS_Utils.i @@ -0,0 +1,43 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +//////////////////////////////////////////////////////////////////////// +// Simple class to deal with smart locking/unlocking of python GIL +//////////////////////////////////////////////////////////////////////// +%{ + +struct PyGILPhondler +{ + PyGILPhondler(void): + s(PyGILState_Ensure()) + { + //NOP + } + ~PyGILPhondler(void) + { + PyGILState_Release(s); + } + PyGILState_STATE s; +}; + +%} + +//////////////////////////////////////////////////////////////////////// +// Simple class to deal with smart save/restore of python thread state +//////////////////////////////////////////////////////////////////////// +%{ + +struct PyTSPhondler +{ + PyTSPhondler(void): + s(PyEval_SaveThread()) + { + //NOP + } + ~PyTSPhondler(void) + { + PyEval_RestoreThread(s); + } + PyThreadState *s; +}; + +%} |