Merge pull request #3616 from neachdainn/3615-gilprotected-pyvisit
Enable `GILProtected` access via `PyVisit`
This commit is contained in:
commit
4baf0235c3
|
@ -0,0 +1 @@
|
|||
Add `traverse` method to `GILProtected`
|
|
@ -1,5 +1,5 @@
|
|||
//! Synchronization mechanisms based on the Python GIL.
|
||||
use crate::{types::PyString, types::PyType, Py, PyErr, Python};
|
||||
use crate::{types::PyString, types::PyType, Py, PyErr, PyVisit, Python};
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
/// Value with concurrent access protected by the GIL.
|
||||
|
@ -37,6 +37,11 @@ impl<T> GILProtected<T> {
|
|||
pub fn get<'py>(&'py self, _py: Python<'py>) -> &'py T {
|
||||
&self.value
|
||||
}
|
||||
|
||||
/// Gain access to the inner value by giving proof that garbage collection is happening.
|
||||
pub fn traverse<'py>(&'py self, _visit: PyVisit<'py>) -> &'py T {
|
||||
&self.value
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T> Sync for GILProtected<T> where T: Send {}
|
||||
|
|
Loading…
Reference in New Issue