comparison src/event-stream.c @ 74:54cc21c15cbb r20-0b32

Import from CVS: tag r20-0b32
author cvs
date Mon, 13 Aug 2007 09:04:33 +0200
parents b9518feda344
children 1ce6082ce73f
comparison
equal deleted inserted replaced
73:e2d7a37b7c8d 74:54cc21c15cbb
1201 event_stream_remove_async_timeout (timeout->interval_id); 1201 event_stream_remove_async_timeout (timeout->interval_id);
1202 else 1202 else
1203 event_stream_remove_timeout (timeout->interval_id); 1203 event_stream_remove_timeout (timeout->interval_id);
1204 free_managed_opaque (Vtimeout_free_list, op); 1204 free_managed_opaque (Vtimeout_free_list, op);
1205 } 1205 }
1206 }
1207
1208 int
1209 event_stream_wakeup_pending_p (int id, int async_p)
1210 {
1211 struct timeout *timeout;
1212 Lisp_Object rest = Qnil;
1213 Lisp_Object timeout_list;
1214 int found = 0;
1215
1216
1217 if (async_p)
1218 timeout_list = pending_async_timeout_list;
1219 else
1220 timeout_list = pending_timeout_list;
1221
1222 /* Find the element on the list of pending ones, if it's still there. */
1223 LIST_LOOP (rest, timeout_list)
1224 {
1225 timeout = (struct timeout *) XOPAQUE_DATA (XCAR (rest));
1226 if (timeout->id == id)
1227 {
1228 found = 1;
1229 break;
1230 }
1231 }
1232
1233 return found;
1206 } 1234 }
1207 1235
1208 1236
1209 /**** Asynch. timeout functions (see also signal.c) ****/ 1237 /**** Asynch. timeout functions (see also signal.c) ****/
1210 1238
2398 loop will process it, and I don't think that there is ever a 2426 loop will process it, and I don't think that there is ever a
2399 time when one calls accept-process-output with a nil argument 2427 time when one calls accept-process-output with a nil argument
2400 and really need the processes to be handled. */ 2428 and really need the processes to be handled. */
2401 || (!EQ (result, Qt) && event_stream_event_pending_p (0))) 2429 || (!EQ (result, Qt) && event_stream_event_pending_p (0)))
2402 { 2430 {
2431 /* If our timeout has arrived, we move along. */
2432 if (!event_stream_wakeup_pending_p (timeout_id, 0))
2433 {
2434 timeout_enabled = 0;
2435 process = Qnil; /* We're done. */
2436 }
2437
2403 QUIT; /* next_event_internal() does not QUIT, so check for ^G 2438 QUIT; /* next_event_internal() does not QUIT, so check for ^G
2404 before reading output from the process - this makes it 2439 before reading output from the process - this makes it
2405 less likely that the filter will actually be aborted. 2440 less likely that the filter will actually be aborted.
2406 */ 2441 */
2407 2442
2424 2459
2425 execute_internal_event (event); 2460 execute_internal_event (event);
2426 break; 2461 break;
2427 } 2462 }
2428 case timeout_event: 2463 case timeout_event:
2429 { 2464 /* We execute the event even if it's ours, and notice that it's
2430 if (timeout_enabled && 2465 happened above. */
2431 XEVENT (event)->event.timeout.id_number == timeout_id)
2432 {
2433 timeout_enabled = 0;
2434 process = Qnil; /* we're done */
2435 }
2436 else /* a timeout that's not the one we're waiting for */
2437 goto EXECUTE_INTERNAL;
2438 break;
2439 }
2440 case pointer_motion_event: 2466 case pointer_motion_event:
2441 case magic_event: 2467 case magic_event:
2442 { 2468 {
2443 EXECUTE_INTERNAL: 2469 EXECUTE_INTERNAL:
2444 execute_internal_event (event); 2470 execute_internal_event (event);
2478 2504
2479 id = event_stream_generate_wakeup (msecs, 0, Qnil, Qnil, 0); 2505 id = event_stream_generate_wakeup (msecs, 0, Qnil, Qnil, 0);
2480 event = Fmake_event (); 2506 event = Fmake_event ();
2481 while (1) 2507 while (1)
2482 { 2508 {
2509 /* If our timeout has arrived, we move along. */
2510 if (!event_stream_wakeup_pending_p (id, 0))
2511 goto DONE_LABEL;
2512
2483 QUIT; /* next_event_internal() does not QUIT, so check for ^G 2513 QUIT; /* next_event_internal() does not QUIT, so check for ^G
2484 before reading output from the process - this makes it 2514 before reading output from the process - this makes it
2485 less likely that the filter will actually be aborted. 2515 less likely that the filter will actually be aborted.
2486 */ 2516 */
2487 /* We're a generator of the command_event_queue, so we can't be a 2517 /* We're a generator of the command_event_queue, so we can't be a
2491 next_event_internal (event, 0); /* blocks */ 2521 next_event_internal (event, 0); /* blocks */
2492 /* See the comment in accept-process-output about Vquit_flag */ 2522 /* See the comment in accept-process-output about Vquit_flag */
2493 switch (XEVENT_TYPE (event)) 2523 switch (XEVENT_TYPE (event))
2494 { 2524 {
2495 case timeout_event: 2525 case timeout_event:
2496 { 2526 /* We execute the event even if it's ours, and notice that it's
2497 if (XEVENT (event)->event.timeout.id_number == id) 2527 happened above. */
2498 goto DONE_LABEL;
2499 else
2500 goto EXECUTE_INTERNAL;
2501 }
2502 case pointer_motion_event: 2528 case pointer_motion_event:
2503 case process_event: 2529 case process_event:
2504 case magic_event: 2530 case magic_event:
2505 { 2531 {
2506 EXECUTE_INTERNAL: 2532 EXECUTE_INTERNAL:
2580 { 2606 {
2581 run_pre_idle_hook (); 2607 run_pre_idle_hook ();
2582 redisplay (); 2608 redisplay ();
2583 } 2609 }
2584 2610
2585 /* If we're no longer waiting for a timeout, bug out. */ 2611 /* If our timeout has arrived, we move along. */
2586 if (! id) 2612 if (!event_stream_wakeup_pending_p (id, 0))
2587 { 2613 {
2588 result = Qt; 2614 result = Qt;
2589 goto DONE_LABEL; 2615 goto DONE_LABEL;
2590 } 2616 }
2591 2617
2612 /* eval-events get delayed until later. */ 2638 /* eval-events get delayed until later. */
2613 enqueue_command_event (Fcopy_event (event, Qnil)); 2639 enqueue_command_event (Fcopy_event (event, Qnil));
2614 break; 2640 break;
2615 } 2641 }
2616 case timeout_event: 2642 case timeout_event:
2617 { 2643 /* We execute the event even if it's ours, and notice that it's
2618 if (XEVENT (event)->event.timeout.id_number != id) 2644 happened above. */
2619 /* a timeout that wasn't the one we're waiting for */ 2645 default:
2620 goto EXECUTE_INTERNAL;
2621 id = 0; /* assert that we are no longer waiting for it. */
2622 result = Qt;
2623 goto DONE_LABEL;
2624 }
2625 default:
2626 { 2646 {
2627 EXECUTE_INTERNAL: 2647 EXECUTE_INTERNAL:
2628 execute_internal_event (event); 2648 execute_internal_event (event);
2629 break; 2649 break;
2630 } 2650 }
2631 } 2651 }
2632 } 2652 }
2633 2653
2634 DONE_LABEL: 2654 DONE_LABEL:
2635 /* If our timeout has not been signalled yet, disable it. */ 2655 /* If our timeout has not been signalled yet, disable it. */
2636 if (id) 2656 if (NILP (result))
2637 event_stream_disable_wakeup (id, 0); 2657 event_stream_disable_wakeup (id, 0);
2638 2658
2639 /* Put back the event (if any) that made Fsit_for() exit before the 2659 /* Put back the event (if any) that made Fsit_for() exit before the
2640 timeout. Note that it is being added to the back of the queue, which 2660 timeout. Note that it is being added to the back of the queue, which
2641 would be inappropriate if there were any user events on the queue 2661 would be inappropriate if there were any user events on the queue