这篇教程C++ HEAD_LOCK函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中HEAD_LOCK函数的典型用法代码示例。如果您正苦于以下问题:C++ HEAD_LOCK函数的具体用法?C++ HEAD_LOCK怎么用?C++ HEAD_LOCK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了HEAD_LOCK函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: PyInterpreterState_DeletevoidPyInterpreterState_Delete(PyInterpreterState *interp){ PyInterpreterState **p; zapthreads(interp); HEAD_LOCK(); for (p = &_PyRuntime.interpreters.head; ; p = &(*p)->next) { if (*p == NULL) Py_FatalError( "PyInterpreterState_Delete: invalid interp"); if (*p == interp) break; } if (interp->tstate_head != NULL) Py_FatalError("PyInterpreterState_Delete: remaining threads"); *p = interp->next; if (_PyRuntime.interpreters.main == interp) { _PyRuntime.interpreters.main = NULL; if (_PyRuntime.interpreters.head != NULL) Py_FatalError("PyInterpreterState_Delete: remaining subinterpreters"); } HEAD_UNLOCK(); if (interp->id_mutex != NULL) { PyThread_free_lock(interp->id_mutex); } if (interp->ceval.pending.lock != NULL) { PyThread_free_lock(interp->ceval.pending.lock); } PyMem_RawFree(interp);}
开发者ID:tiran,项目名称:cpython,代码行数:30,
示例2: _PyInterpreterState_DeleteExceptMain/* * Delete all interpreter states except the main interpreter. If there * is a current interpreter state, it *must* be the main interpreter. */void_PyInterpreterState_DeleteExceptMain(){ PyThreadState *tstate = PyThreadState_Swap(NULL); if (tstate != NULL && tstate->interp != _PyRuntime.interpreters.main) { Py_FatalError("PyInterpreterState_DeleteExceptMain: not main interpreter"); } HEAD_LOCK(); PyInterpreterState *interp = _PyRuntime.interpreters.head; _PyRuntime.interpreters.head = NULL; while (interp != NULL) { if (interp == _PyRuntime.interpreters.main) { _PyRuntime.interpreters.main->next = NULL; _PyRuntime.interpreters.head = interp; interp = interp->next; continue; } PyInterpreterState_Clear(interp); // XXX must activate? zapthreads(interp); if (interp->id_mutex != NULL) { PyThread_free_lock(interp->id_mutex); } PyInterpreterState *prev_interp = interp; interp = interp->next; PyMem_RawFree(prev_interp); } HEAD_UNLOCK(); if (_PyRuntime.interpreters.head == NULL) { Py_FatalError("PyInterpreterState_DeleteExceptMain: missing main"); } PyThreadState_Swap(tstate);}
开发者ID:tiran,项目名称:cpython,代码行数:39,
示例3: _PyThreadState_DeleteExcept/* * Delete all thread states except the one passed as argument. * Note that, if there is a current thread state, it *must* be the one * passed as argument. Also, this won't touch any other interpreters * than the current one, since we don't know which thread state should * be kept in those other interpreteres. */void_PyThreadState_DeleteExcept(PyThreadState *tstate){ PyInterpreterState *interp = tstate->interp; PyThreadState *p, *next, *garbage; HEAD_LOCK(); /* Remove all thread states, except tstate, from the linked list of thread states. This will allow calling PyThreadState_Clear() without holding the lock. */ garbage = interp->tstate_head; if (garbage == tstate) garbage = tstate->next; if (tstate->prev) tstate->prev->next = tstate->next; if (tstate->next) tstate->next->prev = tstate->prev; tstate->prev = tstate->next = NULL; interp->tstate_head = tstate; HEAD_UNLOCK(); /* Clear and deallocate all stale thread states. Even if this executes Python code, we should be safe since it executes in the current thread, not one of the stale threads. */ for (p = garbage; p; p = next) { next = p->next; PyThreadState_Clear(p); PyMem_RawFree(p); }}
开发者ID:Alkalit,项目名称:cpython,代码行数:35,
示例4: PyInterpreterState_ClearvoidPyInterpreterState_Clear(PyInterpreterState *interp){ PyThreadState *p; HEAD_LOCK(); for (p = interp->tstate_head; p != NULL; p = p->next) PyThreadState_Clear(p); HEAD_UNLOCK(); _PyCoreConfig_Clear(&interp->core_config); _PyMainInterpreterConfig_Clear(&interp->config); Py_CLEAR(interp->codec_search_path); Py_CLEAR(interp->codec_search_cache); Py_CLEAR(interp->codec_error_registry); Py_CLEAR(interp->modules); Py_CLEAR(interp->modules_by_index); Py_CLEAR(interp->sysdict); Py_CLEAR(interp->builtins); Py_CLEAR(interp->builtins_copy); Py_CLEAR(interp->importlib); Py_CLEAR(interp->import_func);#ifdef HAVE_FORK Py_CLEAR(interp->before_forkers); Py_CLEAR(interp->after_forkers_parent); Py_CLEAR(interp->after_forkers_child);#endif // XXX Once we have one allocator per interpreter (i.e. // per-interpreter GC) we must ensure that all of the interpreter's // objects have been cleaned up at the point.}
开发者ID:tiran,项目名称:cpython,代码行数:29,
示例5: PyThreadState_SetAsyncExcintPyThreadState_SetAsyncExc(long id, PyObject *exc) { PyThreadState *tstate = PyThreadState_GET(); PyInterpreterState *interp = tstate->interp; PyThreadState *p; /* Although the GIL is held, a few C API functions can be called * without the GIL held, and in particular some that create and * destroy thread and interpreter states. Those can mutate the * list of thread states we're traversing, so to prevent that we lock * head_mutex for the duration. */ HEAD_LOCK(); for (p = interp->tstate_head; p != NULL; p = p->next) { if (p->thread_id == id) { /* Tricky: we need to decref the current value * (if any) in p->async_exc, but that can in turn * allow arbitrary Python code to run, including * perhaps calls to this function. To prevent * deadlock, we need to release head_mutex before * the decref. */ PyObject *old_exc = p->async_exc; Py_XINCREF(exc); p->async_exc = exc; HEAD_UNLOCK(); Py_XDECREF(old_exc); return 1; } } HEAD_UNLOCK(); return 0;}
开发者ID:Av3ng3,项目名称:Lamobo-D1s,代码行数:33,
示例6: PyInterpreterState_DeletevoidPyInterpreterState_Delete(PyInterpreterState *interp){ PyInterpreterState **p; zapthreads(interp); HEAD_LOCK(); for (p = &interp_head; ; p = &(*p)->next) { if (*p == NULL) Py_FatalError( "PyInterpreterState_Delete: invalid interp"); if (*p == interp) break; } if (interp->tstate_head != NULL) Py_FatalError("PyInterpreterState_Delete: remaining threads"); *p = interp->next; HEAD_UNLOCK(); PyMem_RawFree(interp);#ifdef WITH_THREAD if (interp_head == NULL && head_mutex != NULL) { PyThread_free_lock(head_mutex); head_mutex = NULL; }#endif}
开发者ID:Alkalit,项目名称:cpython,代码行数:25,
示例7: new_threadstatestatic PyThreadState *new_threadstate(PyInterpreterState *interp, int init){ PyThreadState *tstate = (PyThreadState *)PyMem_RawMalloc(sizeof(PyThreadState)); if (_PyThreadState_GetFrame == NULL) _PyThreadState_GetFrame = threadstate_getframe; if (tstate != NULL) { tstate->interp = interp; tstate->frame = NULL; tstate->recursion_depth = 0; tstate->overflowed = 0; tstate->recursion_critical = 0; tstate->tracing = 0; tstate->use_tracing = 0; tstate->tick_counter = 0; tstate->gilstate_counter = 0; tstate->async_exc = NULL;#ifdef WITH_THREAD tstate->thread_id = PyThread_get_thread_ident();#else tstate->thread_id = 0;#endif tstate->dict = NULL; tstate->curexc_type = NULL; tstate->curexc_value = NULL; tstate->curexc_traceback = NULL; tstate->exc_type = NULL; tstate->exc_value = NULL; tstate->exc_traceback = NULL; tstate->c_profilefunc = NULL; tstate->c_tracefunc = NULL; tstate->c_profileobj = NULL; tstate->c_traceobj = NULL; tstate->trash_delete_nesting = 0; tstate->trash_delete_later = NULL; tstate->on_delete = NULL; tstate->on_delete_data = NULL; if (init) _PyThreadState_Init(tstate); HEAD_LOCK(); tstate->prev = NULL; tstate->next = interp->tstate_head; if (tstate->next) tstate->next->prev = tstate; interp->tstate_head = tstate; HEAD_UNLOCK(); } return tstate;}
开发者ID:aholkner,项目名称:cpython,代码行数:60,
示例8: PyInterpreterState_NewPyInterpreterState *PyInterpreterState_New(void){ PyInterpreterState *interp = (PyInterpreterState *) PyMem_RawMalloc(sizeof(PyInterpreterState)); if (interp != NULL) { HEAD_INIT();#ifdef WITH_THREAD if (head_mutex == NULL) Py_FatalError("Can't initialize threads for interpreter");#endif interp->modules = NULL; interp->modules_by_index = NULL; interp->sysdict = NULL; interp->builtins = NULL; interp->builtins_copy = NULL; interp->tstate_head = NULL; interp->codec_search_path = NULL; interp->codec_search_cache = NULL; interp->codec_error_registry = NULL; interp->codecs_initialized = 0; interp->fscodec_initialized = 0; interp->importlib = NULL; interp->import_func = NULL; interp->eval_frame = _PyEval_EvalFrameDefault;#ifdef HAVE_DLOPEN#if HAVE_DECL_RTLD_NOW interp->dlopenflags = RTLD_NOW;#else interp->dlopenflags = RTLD_LAZY;#endif#endif#ifdef HAVE_FORK interp->before_forkers = NULL; interp->after_forkers_parent = NULL; interp->after_forkers_child = NULL;#endif HEAD_LOCK(); interp->next = interp_head; if (interp_main == NULL) { interp_main = interp; } interp_head = interp; if (_next_interp_id < 0) { /* overflow or Py_Initialize() not called! */ PyErr_SetString(PyExc_RuntimeError, "failed to get an interpreter ID"); interp = NULL; } else { interp->id = _next_interp_id; _next_interp_id += 1; } HEAD_UNLOCK(); } return interp;}
开发者ID:gyx1000,项目名称:cpython,代码行数:59,
示例9: PyThreadState_NewPyThreadState *PyThreadState_New(PyInterpreterState *interp){ PyThreadState *tstate = (PyThreadState *)malloc(sizeof(PyThreadState)); if (_PyThreadState_GetFrame == NULL) _PyThreadState_GetFrame = threadstate_getframe; if (tstate != NULL) { tstate->interp = interp; tstate->frame = NULL; tstate->recursion_depth = 0; tstate->tracing = 0; tstate->use_tracing = 0; tstate->tick_counter = 0; tstate->gilstate_counter = 0; tstate->async_exc = NULL;#ifdef WITH_THREAD tstate->thread_id = PyThread_get_thread_ident();#else tstate->thread_id = 0;#endif tstate->dict = NULL; tstate->curexc_type = NULL; tstate->curexc_value = NULL; tstate->curexc_traceback = NULL; tstate->exc_type = NULL; tstate->exc_value = NULL; tstate->exc_traceback = NULL; tstate->c_profilefunc = NULL; tstate->c_tracefunc = NULL; tstate->c_profileobj = NULL; tstate->c_traceobj = NULL;#ifdef STACKLESS STACKLESS_PYSTATE_NEW;#endif#ifdef WITH_THREAD _PyGILState_NoteThreadState(tstate);#endif HEAD_LOCK(); tstate->next = interp->tstate_head; interp->tstate_head = tstate; HEAD_UNLOCK(); } return tstate;}
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:54,
示例10: PyInterpreterState_ClearvoidPyInterpreterState_Clear(PyInterpreterState *interp){ PyThreadState *p; HEAD_LOCK(); for (p = interp->tstate_head; p != NULL; p = p->next) PyThreadState_Clear(p); HEAD_UNLOCK(); Py_CLEAR(interp->codec_search_path); Py_CLEAR(interp->codec_search_cache); Py_CLEAR(interp->codec_error_registry); Py_CLEAR(interp->modules); Py_CLEAR(interp->modules_reloading); Py_CLEAR(interp->sysdict); Py_CLEAR(interp->builtins);}
开发者ID:Av3ng3,项目名称:Lamobo-D1s,代码行数:16,
示例11: PyInterpreterState_NewPyInterpreterState *PyInterpreterState_New(void){ PyInterpreterState *interp = (PyInterpreterState *) PyMem_RawMalloc(sizeof(PyInterpreterState)); if (interp != NULL) { HEAD_INIT();#ifdef WITH_THREAD if (head_mutex == NULL) Py_FatalError("Can't initialize threads for interpreter");#endif interp->modules = NULL; interp->modules_by_index = NULL; interp->sysdict = NULL; interp->builtins = NULL; interp->builtins_copy = NULL; interp->tstate_head = NULL; interp->codec_search_path = NULL; interp->codec_search_cache = NULL; interp->codec_error_registry = NULL; interp->codecs_initialized = 0; interp->fscodec_initialized = 0; interp->importlib = NULL;#ifdef HAVE_DLOPEN#ifdef RTLD_NOW interp->dlopenflags = RTLD_NOW;#else interp->dlopenflags = RTLD_LAZY;#endif#endif#ifdef WITH_TSC interp->tscdump = 0;#endif HEAD_LOCK(); interp->next = interp_head; interp_head = interp; HEAD_UNLOCK(); } return interp;}
开发者ID:Alkalit,项目名称:cpython,代码行数:43,
示例12: PyInterpreterState_DeletevoidPyInterpreterState_Delete(PyInterpreterState *interp){ PyInterpreterState **p; zapthreads(interp); HEAD_LOCK(); for (p = &interp_head; ; p = &(*p)->next) { if (*p == NULL) Py_FatalError( "PyInterpreterState_Delete: invalid interp"); if (*p == interp) break; } if (interp->tstate_head != NULL) Py_FatalError("PyInterpreterState_Delete: remaining threads"); *p = interp->next; HEAD_UNLOCK(); free(interp);}
开发者ID:Av3ng3,项目名称:Lamobo-D1s,代码行数:19,
示例13: _PyThread_CurrentFrames/* The implementation of sys._current_frames(). This is intended to be called with the GIL held, as it will be when called via sys._current_frames(). It's possible it would work fine even without the GIL held, but haven't thought enough about that.*/PyObject *_PyThread_CurrentFrames(void){ PyObject *result; PyInterpreterState *i; result = PyDict_New(); if (result == NULL) return NULL; /* for i in all interpreters: * for t in all of i's thread states: * if t's frame isn't NULL, map t's id to its frame * Because these lists can mutate even when the GIL is held, we * need to grab head_mutex for the duration. */ HEAD_LOCK(); for (i = interp_head; i != NULL; i = i->next) { PyThreadState *t; for (t = i->tstate_head; t != NULL; t = t->next) { PyObject *id; int stat; struct _frame *frame = t->frame; if (frame == NULL) continue; id = PyInt_FromLong(t->thread_id); if (id == NULL) goto Fail; stat = PyDict_SetItem(result, id, (PyObject *)frame); Py_DECREF(id); if (stat < 0) goto Fail; } } HEAD_UNLOCK(); return result; Fail: HEAD_UNLOCK(); Py_DECREF(result); return NULL;}
开发者ID:Av3ng3,项目名称:Lamobo-D1s,代码行数:47,
示例14: tstate_delete_common/* Common code for PyThreadState_Delete() and PyThreadState_DeleteCurrent() */static voidtstate_delete_common(PyThreadState *tstate){ PyInterpreterState *interp; if (tstate == NULL) Py_FatalError("PyThreadState_Delete: NULL tstate"); interp = tstate->interp; if (interp == NULL) Py_FatalError("PyThreadState_Delete: NULL interp"); HEAD_LOCK(); if (tstate->prev) tstate->prev->next = tstate->next; else interp->tstate_head = tstate->next; if (tstate->next) tstate->next->prev = tstate->prev; HEAD_UNLOCK(); if (tstate->on_delete != NULL) { tstate->on_delete(tstate->on_delete_data); } PyMem_RawFree(tstate);}
开发者ID:Alkalit,项目名称:cpython,代码行数:23,
示例15: tstate_delete_common/* Common code for PyThreadState_Delete() and PyThreadState_DeleteCurrent() */static voidtstate_delete_common(PyThreadState *tstate){ PyInterpreterState *interp; PyThreadState **p; if (tstate == NULL) Py_FatalError("PyThreadState_Delete: NULL tstate"); interp = tstate->interp; if (interp == NULL) Py_FatalError("PyThreadState_Delete: NULL interp"); HEAD_LOCK(); for (p = &interp->tstate_head; ; p = &(*p)->next) { if (*p == NULL) Py_FatalError( "PyThreadState_Delete: invalid tstate"); if (*p == tstate) break; } *p = tstate->next; HEAD_UNLOCK(); free(tstate);}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:23,
示例16: tstate_delete_common/* Common code for PyThreadState_Delete() and PyThreadState_DeleteCurrent() */static voidtstate_delete_common(PyThreadState *tstate){ PyInterpreterState *interp; PyThreadState **p; PyThreadState *prev_p = NULL; if (tstate == NULL) Py_FatalError("PyThreadState_Delete: NULL tstate"); interp = tstate->interp; if (interp == NULL) Py_FatalError("PyThreadState_Delete: NULL interp"); HEAD_LOCK(); for (p = &interp->tstate_head; ; p = &(*p)->next) { if (*p == NULL) Py_FatalError( "PyThreadState_Delete: invalid tstate"); if (*p == tstate) break; /* Sanity check. These states should never happen but if * they do we must abort. Otherwise we'll end up spinning in * in a tight loop with the lock held. A similar check is done * in thread.c find_key(). */ if (*p == prev_p) Py_FatalError( "PyThreadState_Delete: small circular list(!)" " and tstate not found."); prev_p = *p; if ((*p)->next == interp->tstate_head) Py_FatalError( "PyThreadState_Delete: circular list(!) and" " tstate not found."); } *p = tstate->next; HEAD_UNLOCK(); free(tstate);}
开发者ID:Av3ng3,项目名称:Lamobo-D1s,代码行数:37,
示例17: new_threadstatestatic PyThreadState *new_threadstate(PyInterpreterState *interp, int init){ PyThreadState *tstate = (PyThreadState *)PyMem_RawMalloc(sizeof(PyThreadState)); if (_PyThreadState_GetFrame == NULL) _PyThreadState_GetFrame = threadstate_getframe; if (tstate != NULL) { tstate->interp = interp; tstate->frame = NULL; tstate->recursion_depth = 0; tstate->overflowed = 0; tstate->recursion_critical = 0; tstate->tracing = 0; tstate->use_tracing = 0; tstate->gilstate_counter = 0; tstate->async_exc = NULL;#ifdef WITH_THREAD tstate->thread_id = PyThread_get_thread_ident();#else tstate->thread_id = 0;#endif tstate->dict = NULL; tstate->curexc_type = NULL; tstate->curexc_value = NULL; tstate->curexc_traceback = NULL; tstate->exc_type = NULL; tstate->exc_value = NULL; tstate->exc_traceback = NULL; tstate->c_profilefunc = NULL; tstate->c_tracefunc = NULL; tstate->c_profileobj = NULL; tstate->c_traceobj = NULL; tstate->trash_delete_nesting = 0; tstate->trash_delete_later = NULL; tstate->on_delete = NULL; tstate->on_delete_data = NULL; if (init) _PyThreadState_Init(tstate); HEAD_LOCK(); tstate->prev = NULL; tstate->next = interp->tstate_head; if (tstate->next) tstate->next->prev = tstate; interp->tstate_head = tstate; HEAD_UNLOCK();#if defined _MSC_VER && _MSC_VER >= 1900 /* Issue #23524: Temporary fix to disable termination due to invalid parameters */ _set_thread_local_invalid_parameter_handler((_invalid_parameter_handler)_Py_silent_invalid_parameter_handler);#endif } return tstate;}
开发者ID:zhangweiabc,项目名称:cpython,代码行数:64,
示例18: PyInterpreterState_NewPyInterpreterState *PyInterpreterState_New(void){ PyInterpreterState *interp = (PyInterpreterState *) PyMem_RawMalloc(sizeof(PyInterpreterState)); if (interp == NULL) { return NULL; } memset(interp, 0, sizeof(*interp)); interp->id_refcount = -1; interp->check_interval = 100; interp->ceval.pending.lock = PyThread_allocate_lock(); if (interp->ceval.pending.lock == NULL) { PyErr_SetString(PyExc_RuntimeError, "failed to create interpreter ceval pending mutex"); return NULL; } interp->core_config = _PyCoreConfig_INIT; interp->config = _PyMainInterpreterConfig_INIT; interp->eval_frame = _PyEval_EvalFrameDefault;#ifdef HAVE_DLOPEN#if HAVE_DECL_RTLD_NOW interp->dlopenflags = RTLD_NOW;#else interp->dlopenflags = RTLD_LAZY;#endif#endif if (_PyRuntime.main_thread == 0) { _PyRuntime.main_thread = PyThread_get_thread_ident(); } HEAD_LOCK(); if (_PyRuntime.interpreters.next_id < 0) { /* overflow or Py_Initialize() not called! */ PyErr_SetString(PyExc_RuntimeError, "failed to get an interpreter ID"); PyMem_RawFree(interp); interp = NULL; } else { interp->id = _PyRuntime.interpreters.next_id; _PyRuntime.interpreters.next_id += 1; interp->next = _PyRuntime.interpreters.head; if (_PyRuntime.interpreters.main == NULL) { _PyRuntime.interpreters.main = interp; } _PyRuntime.interpreters.head = interp; } HEAD_UNLOCK(); if (interp == NULL) { return NULL; } interp->tstate_next_unique_id = 0; return interp;}
开发者ID:tiran,项目名称:cpython,代码行数:61,
示例19: new_threadstatestatic PyThreadState *new_threadstate(PyInterpreterState *interp, int init){ PyThreadState *tstate = (PyThreadState *)PyMem_RawMalloc(sizeof(PyThreadState)); if (_PyThreadState_GetFrame == NULL) _PyThreadState_GetFrame = threadstate_getframe; if (tstate != NULL) { tstate->interp = interp; tstate->frame = NULL; tstate->recursion_depth = 0; tstate->overflowed = 0; tstate->recursion_critical = 0; tstate->stackcheck_counter = 0; tstate->tracing = 0; tstate->use_tracing = 0; tstate->gilstate_counter = 0; tstate->async_exc = NULL; tstate->thread_id = PyThread_get_thread_ident(); tstate->dict = NULL; tstate->curexc_type = NULL; tstate->curexc_value = NULL; tstate->curexc_traceback = NULL; tstate->exc_state.exc_type = NULL; tstate->exc_state.exc_value = NULL; tstate->exc_state.exc_traceback = NULL; tstate->exc_state.previous_item = NULL; tstate->exc_info = &tstate->exc_state; tstate->c_profilefunc = NULL; tstate->c_tracefunc = NULL; tstate->c_profileobj = NULL; tstate->c_traceobj = NULL; tstate->trash_delete_nesting = 0; tstate->trash_delete_later = NULL; tstate->on_delete = NULL; tstate->on_delete_data = NULL; tstate->coroutine_origin_tracking_depth = 0; tstate->coroutine_wrapper = NULL; tstate->in_coroutine_wrapper = 0; tstate->async_gen_firstiter = NULL; tstate->async_gen_finalizer = NULL; tstate->context = NULL; tstate->context_ver = 1; tstate->id = ++interp->tstate_next_unique_id; if (init) _PyThreadState_Init(tstate); HEAD_LOCK(); tstate->prev = NULL; tstate->next = interp->tstate_head; if (tstate->next) tstate->next->prev = tstate; interp->tstate_head = tstate; HEAD_UNLOCK(); } return tstate;}
开发者ID:tiran,项目名称:cpython,代码行数:71,
示例20: PyInterpreterState_NewPyInterpreterState *PyInterpreterState_New(void){ PyInterpreterState *interp = (PyInterpreterState *) PyMem_RawMalloc(sizeof(PyInterpreterState)); if (interp == NULL) { return NULL; } interp->id_refcount = -1; interp->id_mutex = NULL; interp->modules = NULL; interp->modules_by_index = NULL; interp->sysdict = NULL; interp->builtins = NULL; interp->builtins_copy = NULL; interp->tstate_head = NULL; interp->check_interval = 100; interp->num_threads = 0; interp->pythread_stacksize = 0; interp->codec_search_path = NULL; interp->codec_search_cache = NULL; interp->codec_error_registry = NULL; interp->codecs_initialized = 0; interp->fscodec_initialized = 0; interp->core_config = _PyCoreConfig_INIT; interp->config = _PyMainInterpreterConfig_INIT; interp->importlib = NULL; interp->import_func = NULL; interp->eval_frame = _PyEval_EvalFrameDefault; interp->co_extra_user_count = 0;#ifdef HAVE_DLOPEN#if HAVE_DECL_RTLD_NOW interp->dlopenflags = RTLD_NOW;#else interp->dlopenflags = RTLD_LAZY;#endif#endif#ifdef HAVE_FORK interp->before_forkers = NULL; interp->after_forkers_parent = NULL; interp->after_forkers_child = NULL;#endif interp->pyexitfunc = NULL; interp->pyexitmodule = NULL; HEAD_LOCK(); interp->next = _PyRuntime.interpreters.head; if (_PyRuntime.interpreters.main == NULL) { _PyRuntime.interpreters.main = interp; } _PyRuntime.interpreters.head = interp; if (_PyRuntime.interpreters.next_id < 0) { /* overflow or Py_Initialize() not called! */ PyErr_SetString(PyExc_RuntimeError, "failed to get an interpreter ID"); /* XXX deallocate! */ interp = NULL; } else { interp->id = _PyRuntime.interpreters.next_id; _PyRuntime.interpreters.next_id += 1; } HEAD_UNLOCK(); interp->tstate_next_unique_id = 0; return interp;}
开发者ID:arizvisa,项目名称:cpython,代码行数:69,
注:本文中的HEAD_LOCK函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ HEAD_UNLOCK函数代码示例 C++ HEADER函数代码示例 |