MCPcopy Index your code
hub / github.com/RustPython/RustPython / CreateEvent

Function CreateEvent

crates/stdlib/src/overlapped.rs:1939–1969  ·  view source on GitHub ↗
(
        event_attributes: PyObjectRef,
        manual_reset: bool,
        initial_state: bool,
        name: Option<String>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

1937
1938 #[pyfunction]
1939 fn CreateEvent(
1940 event_attributes: PyObjectRef,
1941 manual_reset: bool,
1942 initial_state: bool,
1943 name: Option<String>,
1944 vm: &VirtualMachine,
1945 ) -> PyResult<isize> {
1946 if !vm.is_none(&event_attributes) {
1947 return Err(vm.new_value_error("EventAttributes must be None"));
1948 }
1949
1950 let name_wide: Option<Vec<u16>> =
1951 name.map(|n| n.encode_utf16().chain(core::iter::once(0)).collect());
1952 let name_ptr = name_wide
1953 .as_ref()
1954 .map(|n| n.as_ptr())
1955 .unwrap_or(core::ptr::null());
1956
1957 let event = unsafe {
1958 windows_sys::Win32::System::Threading::CreateEventW(
1959 core::ptr::null(),
1960 if manual_reset { 1 } else { 0 },
1961 if initial_state { 1 } else { 0 },
1962 name_ptr,
1963 ) as isize
1964 };
1965 if event == NULL {
1966 return Err(set_from_windows_err(0, vm));
1967 }
1968 Ok(event)
1969 }
1970
1971 #[pyfunction]
1972 fn SetEvent(handle: isize, vm: &VirtualMachine) -> PyResult<()> {

Callers

nothing calls this directly

Calls 10

onceFunction · 0.85
CreateEventWFunction · 0.85
set_from_windows_errFunction · 0.85
collectMethod · 0.80
chainMethod · 0.80
ErrClass · 0.50
is_noneMethod · 0.45
mapMethod · 0.45
as_refMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected