ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.59 by root, Sun Nov 4 18:15:16 2007 UTC vs.
Revision 1.61 by root, Sun Nov 4 19:45:09 2007 UTC

28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31#ifndef EV_STANDALONE 31#ifndef EV_STANDALONE
32# include "config.h" 32# include "config.h"
33
34# if HAVE_CLOCK_GETTIME
35# define EV_USE_MONOTONIC 1
36# define EV_USE_REALTIME 1
37# endif
38
39# if HAVE_SELECT && HAVE_SYS_SELECT_H
40# define EV_USE_SELECT 1
41# endif
42
43# if HAVE_POLL && HAVE_POLL_H
44# define EV_USE_POLL 1
45# endif
46
47# if HAVE_EPOLL && HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H
48# define EV_USE_EPOLL 1
49# endif
50
51# if HAVE_KQUEUE && HAVE_WORKING_KQUEUE && HAVE_SYS_EVENT_H && HAVE_SYS_QUEUE_H
52# define EV_USE_KQUEUE 1
53# endif
54
33#endif 55#endif
34 56
35#include <math.h> 57#include <math.h>
36#include <stdlib.h> 58#include <stdlib.h>
37#include <unistd.h> 59#include <unistd.h>
349 /* this should be highly optimised to not do anything but set a flag */ 371 /* this should be highly optimised to not do anything but set a flag */
350 for (fd = 0; fd < anfdmax; ++fd) 372 for (fd = 0; fd < anfdmax; ++fd)
351 if (anfds [fd].events) 373 if (anfds [fd].events)
352 { 374 {
353 anfds [fd].events = 0; 375 anfds [fd].events = 0;
354 fd_change (fd); 376 fd_change (EV_A_ fd);
355 } 377 }
356} 378}
357 379
358/*****************************************************************************/ 380/*****************************************************************************/
359 381
641{ 663{
642 struct ev_loop *loop = (struct ev_loop *)calloc (1, sizeof (struct ev_loop)); 664 struct ev_loop *loop = (struct ev_loop *)calloc (1, sizeof (struct ev_loop));
643 665
644 loop_init (EV_A_ methods); 666 loop_init (EV_A_ methods);
645 667
646 if (ev_methods (EV_A)) 668 if (ev_method (EV_A))
647 return loop; 669 return loop;
648 670
649 return 0; 671 return 0;
650} 672}
651 673
728 750
729 loop_destroy (EV_A); 751 loop_destroy (EV_A);
730} 752}
731 753
732void 754void
733ev_default_fork (EV_P) 755ev_default_fork (void)
734{ 756{
757#if EV_MULTIPLICITY
758 struct ev_loop *loop = default_loop;
759#endif
760
735 loop_fork (EV_A); 761 loop_fork (EV_A);
736 762
737 ev_io_stop (EV_A_ &sigev); 763 ev_io_stop (EV_A_ &sigev);
738 close (sigpipe [0]); 764 close (sigpipe [0]);
739 close (sigpipe [1]); 765 close (sigpipe [1]);
767timers_reify (EV_P) 793timers_reify (EV_P)
768{ 794{
769 while (timercnt && timers [0]->at <= mn_now) 795 while (timercnt && timers [0]->at <= mn_now)
770 { 796 {
771 struct ev_timer *w = timers [0]; 797 struct ev_timer *w = timers [0];
798
799 assert (("inactive timer on timer heap detected", ev_is_active (w)));
772 800
773 /* first reschedule or stop timer */ 801 /* first reschedule or stop timer */
774 if (w->repeat) 802 if (w->repeat)
775 { 803 {
776 assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.)); 804 assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.));
789{ 817{
790 while (periodiccnt && periodics [0]->at <= rt_now) 818 while (periodiccnt && periodics [0]->at <= rt_now)
791 { 819 {
792 struct ev_periodic *w = periodics [0]; 820 struct ev_periodic *w = periodics [0];
793 821
822 assert (("inactive timer on periodic heap detected", ev_is_active (w)));
823
794 /* first reschedule or stop timer */ 824 /* first reschedule or stop timer */
795 if (w->interval) 825 if (w->interval)
796 { 826 {
797 w->at += floor ((rt_now - w->at) / w->interval + 1.) * w->interval; 827 w->at += floor ((rt_now - w->at) / w->interval + 1.) * w->interval;
798 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", w->at > rt_now)); 828 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", w->at > rt_now));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines