4
4
use super :: objtype:: PyClassRef ;
5
5
use crate :: function:: { FunctionBox , OptionalArg , OwnedParam , RefParam } ;
6
6
use crate :: pyobject:: {
7
- IntoPyObject , PyClassImpl , PyContext , PyObjectRef , PyRef , PyResult , PyValue , TryFromObject ,
8
- TypeProtocol ,
7
+ IntoPyObject , PyClassImpl , PyContext , PyObjectRef , PyRef , PyResult , PyValue , ThreadSafe ,
8
+ TryFromObject , TypeProtocol ,
9
9
} ;
10
10
use crate :: slots:: SlotDescriptor ;
11
11
use crate :: vm:: VirtualMachine ;
12
12
13
- pub type PyGetterFunc = FunctionBox < dyn Fn ( & VirtualMachine , PyObjectRef ) -> PyResult > ;
13
+ pub type PyGetterFunc = FunctionBox < dyn Fn ( & VirtualMachine , PyObjectRef ) -> PyResult + Send + Sync > ;
14
14
pub type PySetterFunc =
15
- FunctionBox < dyn Fn ( & VirtualMachine , PyObjectRef , PyObjectRef ) -> PyResult < ( ) > > ;
15
+ FunctionBox < dyn Fn ( & VirtualMachine , PyObjectRef , PyObjectRef ) -> PyResult < ( ) > + Send + Sync > ;
16
16
17
17
pub trait IntoPyGetterFunc < T > {
18
18
fn into_getter ( self ) -> PyGetterFunc ;
19
19
}
20
20
21
21
impl < F , T , R > IntoPyGetterFunc < ( OwnedParam < T > , R , VirtualMachine ) > for F
22
22
where
23
- F : Fn ( T , & VirtualMachine ) -> R + ' static ,
23
+ F : Fn ( T , & VirtualMachine ) -> R + ' static + Send + Sync ,
24
24
T : TryFromObject ,
25
25
R : IntoPyObject ,
26
26
{
34
34
35
35
impl < F , S , R > IntoPyGetterFunc < ( RefParam < S > , R , VirtualMachine ) > for F
36
36
where
37
- F : Fn ( & S , & VirtualMachine ) -> R + ' static ,
37
+ F : Fn ( & S , & VirtualMachine ) -> R + ' static + Send + Sync ,
38
38
S : PyValue ,
39
39
R : IntoPyObject ,
40
40
{
48
48
49
49
impl < F , T , R > IntoPyGetterFunc < ( OwnedParam < T > , R ) > for F
50
50
where
51
- F : Fn ( T ) -> R + ' static ,
51
+ F : Fn ( T ) -> R + ' static + Send + Sync ,
52
52
T : TryFromObject ,
53
53
R : IntoPyObject ,
54
54
{
59
59
60
60
impl < F , S , R > IntoPyGetterFunc < ( RefParam < S > , R ) > for F
61
61
where
62
- F : Fn ( & S ) -> R + ' static ,
62
+ F : Fn ( & S ) -> R + ' static + Send + Sync ,
63
63
S : PyValue ,
64
64
R : IntoPyObject ,
65
65
{
@@ -90,7 +90,7 @@ pub trait IntoPySetterFunc<T> {
90
90
91
91
impl < F , T , V , R > IntoPySetterFunc < ( OwnedParam < T > , V , R , VirtualMachine ) > for F
92
92
where
93
- F : Fn ( T , V , & VirtualMachine ) -> R + ' static ,
93
+ F : Fn ( T , V , & VirtualMachine ) -> R + ' static + Send + Sync ,
94
94
T : TryFromObject ,
95
95
V : TryFromObject ,
96
96
R : IntoPyNoResult ,
@@ -106,7 +106,7 @@ where
106
106
107
107
impl < F , S , V , R > IntoPySetterFunc < ( RefParam < S > , V , R , VirtualMachine ) > for F
108
108
where
109
- F : Fn ( & S , V , & VirtualMachine ) -> R + ' static ,
109
+ F : Fn ( & S , V , & VirtualMachine ) -> R + ' static + Send + Sync ,
110
110
S : PyValue ,
111
111
V : TryFromObject ,
112
112
R : IntoPyNoResult ,
@@ -122,7 +122,7 @@ where
122
122
123
123
impl < F , T , V , R > IntoPySetterFunc < ( OwnedParam < T > , V , R ) > for F
124
124
where
125
- F : Fn ( T , V ) -> R + ' static ,
125
+ F : Fn ( T , V ) -> R + ' static + Send + Sync ,
126
126
T : TryFromObject ,
127
127
V : TryFromObject ,
128
128
R : IntoPyNoResult ,
@@ -134,7 +134,7 @@ where
134
134
135
135
impl < F , S , V , R > IntoPySetterFunc < ( RefParam < S > , V , R ) > for F
136
136
where
137
- F : Fn ( & S , V ) -> R + ' static ,
137
+ F : Fn ( & S , V ) -> R + ' static + Send + Sync ,
138
138
S : PyValue ,
139
139
V : TryFromObject ,
140
140
R : IntoPyNoResult ,
@@ -152,6 +152,8 @@ pub struct PyGetSet {
152
152
// doc: Option<String>,
153
153
}
154
154
155
+ impl ThreadSafe for PyGetSet { }
156
+
155
157
impl std:: fmt:: Debug for PyGetSet {
156
158
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
157
159
write ! (
0 commit comments