forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread.rs
More file actions
30 lines (24 loc) · 859 Bytes
/
thread.rs
File metadata and controls
30 lines (24 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/// Implementation of the _thread module, currently noop implementation as RustPython doesn't yet
/// support threading
use super::super::pyobject::PyObjectRef;
use crate::function::PyFuncArgs;
use crate::pyobject::PyResult;
use crate::vm::VirtualMachine;
fn rlock_acquire(vm: &VirtualMachine, _args: PyFuncArgs) -> PyResult {
Ok(vm.get_none())
}
fn rlock_release(_zelf: PyObjectRef, _vm: &VirtualMachine) {}
fn get_ident(_vm: &VirtualMachine) -> u32 {
1
}
pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
let ctx = &vm.ctx;
let rlock_type = py_class!(ctx, "_thread.RLock", ctx.object(), {
"acquire" => ctx.new_rustfunc(rlock_acquire),
"release" => ctx.new_rustfunc(rlock_release),
});
py_module!(vm, "_thread", {
"RLock" => rlock_type,
"get_ident" => ctx.new_rustfunc(get_ident)
})
}