File tree 1 file changed +56
-0
lines changed
Filter options
1 file changed +56
-0
lines changed
Original file line number Diff line number Diff line change @@ -297,6 +297,10 @@ mod _overlapped {
297
297
}
298
298
}
299
299
300
+ unsafe fn u64_to_handle ( raw_ptr_value : u64 ) -> HANDLE {
301
+ raw_ptr_value as HANDLE
302
+ }
303
+
300
304
#[ pyfunction]
301
305
fn CreateIoCompletionPort (
302
306
handle : isize ,
@@ -354,4 +358,56 @@ mod _overlapped {
354
358
] ) ;
355
359
Ok ( value. into ( ) )
356
360
}
361
+
362
+ #[ pyfunction]
363
+ fn CreateEvent (
364
+ event_attributes : PyObjectRef ,
365
+ manual_reset : bool ,
366
+ initial_state : bool ,
367
+ name : Option < String > ,
368
+ vm : & VirtualMachine ,
369
+ ) -> PyResult < isize > {
370
+ if !vm. is_none ( & event_attributes) {
371
+ return Err ( vm. new_value_error ( "EventAttributes must be None" . to_owned ( ) ) ) ;
372
+ }
373
+
374
+ let name = match name {
375
+ Some ( name) => {
376
+ let name = widestring:: WideCString :: from_str ( & name) . unwrap ( ) ;
377
+ name. as_ptr ( )
378
+ }
379
+ None => std:: ptr:: null ( ) ,
380
+ } ;
381
+ let event = unsafe {
382
+ windows_sys:: Win32 :: System :: Threading :: CreateEventW (
383
+ std:: ptr:: null ( ) ,
384
+ manual_reset as _ ,
385
+ initial_state as _ ,
386
+ name,
387
+ ) as isize
388
+ } ;
389
+ if event == NULL {
390
+ return Err ( errno_err ( vm) ) ;
391
+ }
392
+ Ok ( event)
393
+ }
394
+
395
+ #[ pyfunction]
396
+ fn SetEvent ( handle : u64 , vm : & VirtualMachine ) -> PyResult < ( ) > {
397
+ let ret = unsafe { windows_sys:: Win32 :: System :: Threading :: SetEvent ( u64_to_handle ( handle) ) } ;
398
+ if ret == 0 {
399
+ return Err ( errno_err ( vm) ) ;
400
+ }
401
+ Ok ( ( ) )
402
+ }
403
+
404
+ #[ pyfunction]
405
+ fn ResetEvent ( handle : u64 , vm : & VirtualMachine ) -> PyResult < ( ) > {
406
+ let ret =
407
+ unsafe { windows_sys:: Win32 :: System :: Threading :: ResetEvent ( u64_to_handle ( handle) ) } ;
408
+ if ret == 0 {
409
+ return Err ( errno_err ( vm) ) ;
410
+ }
411
+ Ok ( ( ) )
412
+ }
357
413
}
You can’t perform that action at this time.
0 commit comments