Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
2f6662e1
Commit
2f6662e1
authored
Apr 25, 2016
by
Wenzel Jakob
Browse files
Python 2.7.x fixes for new gil_scoped_release
parent
084ca0e5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
include/pybind11/pybind11.h
include/pybind11/pybind11.h
+15
-4
No files found.
include/pybind11/pybind11.h
View file @
2f6662e1
...
@@ -1122,15 +1122,26 @@ class gil_scoped_release {
...
@@ -1122,15 +1122,26 @@ class gil_scoped_release {
public:
public:
gil_scoped_release
(
bool
disassoc
=
false
)
:
disassoc
(
disassoc
)
{
gil_scoped_release
(
bool
disassoc
=
false
)
:
disassoc
(
disassoc
)
{
tstate
=
PyEval_SaveThread
();
tstate
=
PyEval_SaveThread
();
if
(
disassoc
)
if
(
disassoc
)
{
PyThread_set_key_value
(
detail
::
get_internals
().
tstate
,
nullptr
);
int
key
=
detail
::
get_internals
().
tstate
;
#if PY_MAJOR_VERSION < 3
PyThread_delete_key_value
(
key
);
#else
PyThread_set_key_value
(
key
,
nullptr
);
#endif
}
}
}
~
gil_scoped_release
()
{
~
gil_scoped_release
()
{
if
(
!
tstate
)
if
(
!
tstate
)
return
;
return
;
PyEval_RestoreThread
(
tstate
);
PyEval_RestoreThread
(
tstate
);
if
(
disassoc
)
if
(
disassoc
)
{
PyThread_set_key_value
(
detail
::
get_internals
().
tstate
,
tstate
);
int
key
=
detail
::
get_internals
().
tstate
;
#if PY_MAJOR_VERSION < 3
PyThread_delete_key_value
(
key
);
#endif
PyThread_set_key_value
(
key
,
tstate
);
}
}
}
private:
private:
PyThreadState
*
tstate
;
PyThreadState
*
tstate
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment