comparison src/w32xfns.c @ 22077:ae5e3b23c7e2

(interrupt_handle): New variable. (init_crit): Initialize it. (delete_crit): Cleanup on exit. (signal_quit): New function. Signal any threads that are blocked on a "system" call (provided they have been specially written to check for this), so the call can fail with EINTR as on Unix.
author Richard M. Stallman <rms@gnu.org>
date Fri, 15 May 1998 20:53:39 +0000
parents 639881f2750d
children afcb561b535d
comparison
equal deleted inserted replaced
22076:3313e702e442 22077:ae5e3b23c7e2
31 #define myfree(lp) GlobalFreePtr (lp) 31 #define myfree(lp) GlobalFreePtr (lp)
32 32
33 CRITICAL_SECTION critsect; 33 CRITICAL_SECTION critsect;
34 extern HANDLE keyboard_handle; 34 extern HANDLE keyboard_handle;
35 HANDLE input_available = NULL; 35 HANDLE input_available = NULL;
36 HANDLE interrupt_handle = NULL;
36 37
37 void 38 void
38 init_crit () 39 init_crit ()
39 { 40 {
40 InitializeCriticalSection (&critsect); 41 InitializeCriticalSection (&critsect);
41 42
42 /* For safety, input_available should only be reset by get_next_msg 43 /* For safety, input_available should only be reset by get_next_msg
43 when the input queue is empty, so make it a manual reset event. */ 44 when the input queue is empty, so make it a manual reset event. */
44 keyboard_handle = input_available = CreateEvent (NULL, TRUE, FALSE, NULL); 45 keyboard_handle = input_available = CreateEvent (NULL, TRUE, FALSE, NULL);
46
47 /* interrupt_handle is signalled when quit (C-g) is detected, so that
48 blocking system calls can be interrupted. We make it a manual
49 reset event, so that if we should ever have multiple threads
50 performing system calls, they will all be interrupted (I'm guessing
51 that would the right response). Note that we use PulseEvent to
52 signal this event, so that it never remains signalled. */
53 interrupt_handle = CreateEvent (NULL, TRUE, FALSE, NULL);
45 } 54 }
46 55
47 void 56 void
48 delete_crit () 57 delete_crit ()
49 { 58 {
52 if (input_available) 61 if (input_available)
53 { 62 {
54 CloseHandle (input_available); 63 CloseHandle (input_available);
55 input_available = NULL; 64 input_available = NULL;
56 } 65 }
66 if (interrupt_handle)
67 {
68 CloseHandle (interrupt_handle);
69 interrupt_handle = NULL;
70 }
71 }
72
73 void
74 signal_quit ()
75 {
76 /* Make sure this event never remains signalled; if the main thread
77 isn't in a blocking call, then this should do nothing. */
78 PulseEvent (interrupt_handle);
57 } 79 }
58 80
59 void 81 void
60 select_palette (FRAME_PTR f, HDC hdc) 82 select_palette (FRAME_PTR f, HDC hdc)
61 { 83 {