The schedule_run function is only called by the frontends so remove it from the core header and add its definition to the frontend headers.
Alter the framebuffer schedule_run to return the time untill the next event. svn path=/trunk/netsurf/; revision=10512
This commit is contained in:
parent
085f6b33ec
commit
2fd1476f8c
|
@ -34,4 +34,7 @@ struct nscallback
|
|||
};
|
||||
|
||||
void ami_remove_timer_event(struct nscallback *nscb);
|
||||
|
||||
bool schedule_run(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -293,7 +293,6 @@ bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap,
|
|||
/* In platform specific schedule.c. */
|
||||
void schedule(int t, void (*callback)(void *p), void *p);
|
||||
void schedule_remove(void (*callback)(void *p), void *p);
|
||||
bool schedule_run(void);
|
||||
|
||||
/* In platform specific theme_install.c. */
|
||||
#ifdef WITH_THEME_INSTALL
|
||||
|
|
|
@ -472,12 +472,18 @@ void gui_multitask(void)
|
|||
void gui_poll(bool active)
|
||||
{
|
||||
nsfb_event_t event;
|
||||
int timeout = 0;
|
||||
int timeout;
|
||||
|
||||
active |= schedule_run() | redraws_pending;
|
||||
/* run the scheduler and discover how long to wait for the next event */
|
||||
timeout = schedule_run();
|
||||
|
||||
if (!active)
|
||||
timeout = -1;
|
||||
/* if active do not wait for event, return immediately */
|
||||
if (active)
|
||||
timeout = 0;
|
||||
|
||||
/* if redraws are pending do not wait for event, return immediately */
|
||||
if (redraws_pending)
|
||||
timeout = 0;
|
||||
|
||||
if (fbtk_event(fbtk, &event, timeout)) {
|
||||
if ((event.type == NSFB_EVENT_CONTROL) &&
|
||||
|
|
|
@ -123,21 +123,27 @@ void schedule_remove(void (*callback)(void *p), void *p)
|
|||
}
|
||||
|
||||
/**
|
||||
* Process events up to current time.
|
||||
* Process scheduled callbacks up to current time.
|
||||
*
|
||||
* @return The number of centiseconds untill the next callback or -1 for never.
|
||||
*/
|
||||
|
||||
bool schedule_run(void)
|
||||
int
|
||||
schedule_run(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timeval nexttime;
|
||||
struct timeval rettime;
|
||||
struct nscallback *cur_nscb;
|
||||
struct nscallback *prev_nscb;
|
||||
struct nscallback *unlnk_nscb;
|
||||
|
||||
if (schedule_list == NULL)
|
||||
return false;
|
||||
return -1;
|
||||
|
||||
/* reset enumeration to the start of the list */
|
||||
cur_nscb = schedule_list;
|
||||
prev_nscb = NULL;
|
||||
nexttime = cur_nscb->tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
|
@ -161,19 +167,33 @@ bool schedule_run(void)
|
|||
|
||||
free(unlnk_nscb);
|
||||
|
||||
/* the callback might have modded the list, so start
|
||||
* again
|
||||
*/
|
||||
/* need to deal with callback modifying the list. */
|
||||
if (schedule_list == NULL)
|
||||
return -1; /* no more callbacks scheduled */
|
||||
|
||||
/* reset enumeration to the start of the list */
|
||||
cur_nscb = schedule_list;
|
||||
prev_nscb = NULL;
|
||||
|
||||
nexttime = cur_nscb->tv;
|
||||
} else {
|
||||
/* if the time to the event is sooner than the
|
||||
* currently recorded soonest event record it
|
||||
*/
|
||||
if (timercmp(&nexttime, &cur_nscb->tv, >)) {
|
||||
nexttime = cur_nscb->tv;
|
||||
}
|
||||
/* move to next element */
|
||||
prev_nscb = cur_nscb;
|
||||
cur_nscb = prev_nscb->next;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
/* make rettime relative to now */
|
||||
timersub(&nexttime, &tv, &rettime);
|
||||
|
||||
LOG(("returning time to next event as %ldcs",(rettime.tv_sec * 100) + (rettime.tv_usec / 10000)));
|
||||
/* return next event time in cs */
|
||||
return (rettime.tv_sec * 100) + (rettime.tv_usec / 10000);
|
||||
}
|
||||
|
||||
void list_schedule(void)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#ifndef FRAMEBUFFER_SCHEDULE_H
|
||||
#define FRAMEBUFFER_SCHEDULE_H
|
||||
|
||||
int schedule_run(void);
|
||||
void list_schedule(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,5 +20,6 @@
|
|||
#define NETSURF_GTK_CALLBACK_H 1
|
||||
|
||||
typedef void (*gtk_callback)(void *p);
|
||||
bool schedule_run(void);
|
||||
|
||||
#endif /* NETSURF_GTK_CALLBACK_H */
|
||||
|
|
|
@ -193,6 +193,7 @@ bits ro_filetype_from_unix_path(const char *unix_path);
|
|||
/* in schedule.c */
|
||||
extern bool sched_active;
|
||||
extern os_t sched_time;
|
||||
bool schedule_run(void);
|
||||
|
||||
/* in debugwin.c */
|
||||
void ro_gui_debugwin_open(void);
|
||||
|
|
|
@ -21,5 +21,6 @@
|
|||
#define _NETSURF_WINDOWS_SCHEDULE_H_
|
||||
|
||||
void list_schedule(void);
|
||||
bool schedule_run(void);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue