Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: third_party/libevent/event.c

Issue 7262011: Change MessagePumpLibevent::Run to handle IO events before doing idle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« base/message_pump_libevent.cc ('K') | « base/message_pump_libevent.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2000-2004 Niels Provos <provos@citi.umich.edu> 2 * Copyright (c) 2000-2004 Niels Provos <provos@citi.umich.edu>
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 462 }
463 463
464 int 464 int
465 event_base_loop(struct event_base *base, int flags) 465 event_base_loop(struct event_base *base, int flags)
466 { 466 {
467 const struct eventop *evsel = base->evsel; 467 const struct eventop *evsel = base->evsel;
468 void *evbase = base->evbase; 468 void *evbase = base->evbase;
469 struct timeval tv; 469 struct timeval tv;
470 struct timeval *tv_p; 470 struct timeval *tv_p;
471 int res, done; 471 int res, done;
472 int processed_active = 0;
472 473
473 /* clear time cache */ 474 /* clear time cache */
474 base->tv_cache.tv_sec = 0; 475 base->tv_cache.tv_sec = 0;
475 476
476 if (base->sig.ev_signal_added) 477 if (base->sig.ev_signal_added)
477 evsignal_base = base; 478 evsignal_base = base;
478 done = 0; 479 done = 0;
479 while (!done) { 480 while (!done) {
480 /* Terminate the loop if we have been asked to */ 481 /* Terminate the loop if we have been asked to */
481 if (base->event_gotterm) { 482 if (base->event_gotterm) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 res = evsel->dispatch(base, evbase, tv_p); 517 res = evsel->dispatch(base, evbase, tv_p);
517 518
518 if (res == -1) 519 if (res == -1)
519 return (-1); 520 return (-1);
520 gettime(base, &base->tv_cache); 521 gettime(base, &base->tv_cache);
521 522
522 timeout_process(base); 523 timeout_process(base);
523 524
524 if (base->event_count_active) { 525 if (base->event_count_active) {
525 event_process_active(base); 526 event_process_active(base);
527 processed_active = 1;
526 if (!base->event_count_active && (flags & EVLOOP_ONCE)) 528 if (!base->event_count_active && (flags & EVLOOP_ONCE))
527 done = 1; 529 done = 1;
528 } else if (flags & EVLOOP_NONBLOCK) 530 } else if (flags & EVLOOP_NONBLOCK)
529 done = 1; 531 done = 1;
530 } 532 }
531 533
532 /* clear time cache */ 534 /* clear time cache */
533 base->tv_cache.tv_sec = 0; 535 base->tv_cache.tv_sec = 0;
534 536
535 event_debug(("%s: asked to terminate loop.", __func__)); 537 event_debug(("%s: asked to terminate loop.", __func__));
536 » return (0); 538 » return (processed_active ? 2 : 0);
wtc 2011/06/25 00:39:45 The return value 0 means success. 1 means no even
537 } 539 }
538 540
539 /* Sets up an event for processing once */ 541 /* Sets up an event for processing once */
540 542
541 struct event_once { 543 struct event_once {
542 struct event ev; 544 struct event ev;
543 545
544 void (*cb)(int, short, void *); 546 void (*cb)(int, short, void *);
545 void *arg; 547 void *arg;
546 }; 548 };
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 /* 995 /*
994 * No thread-safe interface needed - the information should be the same 996 * No thread-safe interface needed - the information should be the same
995 * for all threads. 997 * for all threads.
996 */ 998 */
997 999
998 const char * 1000 const char *
999 event_get_method(void) 1001 event_get_method(void)
1000 { 1002 {
1001 return (current_base->evsel->name); 1003 return (current_base->evsel->name);
1002 } 1004 }
OLDNEW
« base/message_pump_libevent.cc ('K') | « base/message_pump_libevent.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698