pystate.h 708 B

123456789101112131415161718192021222324252627282930
  1. #ifndef Py_PYSTATE_H
  2. #define Py_PYSTATE_H
  3. struct _ts; /* Forward */
  4. struct _is; /* Forward */
  5. typedef struct _is {
  6. struct _is *next;
  7. } PyInterpreterState;
  8. typedef struct _ts {
  9. PyInterpreterState *interp;
  10. PyObject *dict; /* Stores per-thread state */
  11. } PyThreadState;
  12. #define Py_BEGIN_ALLOW_THREADS { \
  13. PyThreadState *_save; \
  14. _save = PyEval_SaveThread();
  15. #define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
  16. #define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
  17. #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
  18. }
  19. enum {PyGILState_LOCKED, PyGILState_UNLOCKED};
  20. typedef int PyGILState_STATE;
  21. #define PyThreadState_GET() PyThreadState_Get()
  22. #endif /* !Py_PYSTATE_H */