From 4b2101ba6ab62ae26d82cc8b86e0e61e9c007156 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 19 Jun 2014 18:27:24 +0100 Subject: clean up the fetcher factory and improve its API --- amiga/Makefile.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'amiga') diff --git a/amiga/Makefile.target b/amiga/Makefile.target index c90027465..ea765af36 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -2,7 +2,7 @@ # Amiga target setup # ---------------------------------------------------------------------------- -CFLAGS += -std=c99 -Dnsamiga -DFETCHER_CURLL_SCHEDULED +CFLAGS += -std=c99 -Dnsamiga ifneq ($(SUBTARGET),os3) CFLAGS += -U__STRICT_ANSI__ -D__USE_INLINE__ -D__USE_BASETYPE__ -- cgit v1.2.3 From 8944edd649e74e4864f36d7293921385ba5ca2c7 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 26 Jun 2014 18:56:42 +0100 Subject: convert all frontends to scheduled fetch operation --- amiga/gui.c | 9 ------ atari/gui.c | 5 ++-- beos/gui.cpp | 34 ++++++++--------------- cocoa/gui.m | 2 +- content/fetch.c | 1 + framebuffer/gui.c | 4 --- gtk/gui.c | 69 +++++++++++++++++++--------------------------- monkey/poll.c | 82 +++++++++++++++++++++++-------------------------------- riscos/gui.c | 11 ++------ windows/gui.c | 5 ---- 10 files changed, 80 insertions(+), 142 deletions(-) (limited to 'amiga') diff --git a/amiga/gui.c b/amiga/gui.c index 756ed63e2..e2bb39c0c 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -2502,18 +2502,9 @@ void ami_get_msg(void) ami_quit_netsurf_delayed(); } -static void ami_gui_fetch_callback(void *p) -{ - /* This doesn't need to do anything - the scheduled event will - * send a message to trigger Wait() to return, thereby causing - * the event function to return, and NetSurf to call - * hlcache_poll() as part of the usual fetch/event loop. - */ -} static void gui_poll(bool active) { - if(active) ami_schedule(0, ami_gui_fetch_callback, NULL); ami_get_msg(); } diff --git a/atari/gui.c b/atari/gui.c index 7cac90c3b..608d0d859 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -121,7 +121,7 @@ static void gui_poll(bool active) aes_event_in.emi_tlow = schedule_run(); - if(active || rendering){ + if(rendering){ aes_event_in.emi_tlow = nsoption_int(atari_gui_poll_timeout); } @@ -130,11 +130,10 @@ static void gui_poll(bool active) printf("long poll!\n"); } - if( !active ) { if(input_window && input_window->root->redraw_slots.areas_used > 0) { window_process_redraws(input_window->root); } - } + graf_mkstate(&mx, &my, &dummy, &dummy); aes_event_in.emi_m1.g_x = mx; diff --git a/beos/gui.cpp b/beos/gui.cpp index db4374512..8518ba1ac 100644 --- a/beos/gui.cpp +++ b/beos/gui.cpp @@ -46,7 +46,7 @@ extern "C" { #include "content/content.h" #include "content/content_protected.h" #include "content/fetch.h" -#include "content/fetchers/curl.h" +#include "content/fetchers.h" #include "content/fetchers/resource.h" #include "content/hlcache.h" #include "content/urldb.h" @@ -702,32 +702,23 @@ void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaf static void gui_poll(bool active) { - CURLMcode code; fd_set read_fd_set, write_fd_set, exc_fd_set; - int max_fd = 0; + int max_fd; struct timeval timeout; unsigned int fd_count = 0; bool block = true; bigtime_t next_schedule = 0; - // handle early deadlines - schedule_run(); + /* get any active fetcher fd */ + fetcher_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd); - FD_ZERO(&read_fd_set); - FD_ZERO(&write_fd_set); - FD_ZERO(&exc_fd_set); - - if (active) { - code = curl_multi_fdset(fetch_curl_multi, - &read_fd_set, - &write_fd_set, - &exc_fd_set, - &max_fd); - assert(code == CURLM_OK); - } + /* run the scheduler */ + schedule_run(); // our own event pipe FD_SET(sEventPipe[0], &read_fd_set); + + /** @todo Check if this max_fd should have + 1 */ max_fd = MAX(max_fd, sEventPipe[0] + 1); // If there are pending events elsewhere, we should not be blocking @@ -741,8 +732,10 @@ static void gui_poll(bool active) if (next_schedule < 0) next_schedule = 0; - } else //we're not allowed to sleep, there is other activity going on. + } else {//we're not allowed to sleep, there is other activity going on. + nsbeos_window_process_reformats(); block = false; + } /* LOG(("gui_poll: browser_reformat_pending:%d earliest_callback_timeout:%Ld" @@ -767,11 +760,6 @@ static void gui_poll(bool active) nsbeos_dispatch_event(message); } } - - schedule_run(); - - if (browser_reformat_pending) - nsbeos_window_process_reformats(); } diff --git a/cocoa/gui.m b/cocoa/gui.m index 1cb19a756..713f456cd 100644 --- a/cocoa/gui.m +++ b/cocoa/gui.m @@ -53,7 +53,7 @@ static void gui_poll(bool active) { cocoa_autorelease(); - NSEvent *event = [NSApp nextEventMatchingMask: NSAnyEventMask untilDate: active ? nil : [NSDate distantFuture] + NSEvent *event = [NSApp nextEventMatchingMask: NSAnyEventMask untilDate: [NSDate distantFuture] inMode: NSDefaultRunLoopMode dequeue: YES]; if (nil != event) { diff --git a/content/fetch.c b/content/fetch.c index 10cac9b27..3d1183aa0 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -61,6 +61,7 @@ /* Define this to turn on verbose fetch logging */ #undef DEBUG_FETCH_VERBOSE +#define DEBUG_FETCH_VERBOSE /** The maximum number of fetchers that can be added */ #define MAX_FETCHERS 8 diff --git a/framebuffer/gui.c b/framebuffer/gui.c index 251326dc2..0632bf3c6 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -564,10 +564,6 @@ static void framebuffer_poll(bool active) /* run the scheduler and discover how long to wait for the next event */ timeout = schedule_run(); - /* 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 (fbtk_get_redraw_pending(fbtk)) timeout = 0; diff --git a/gtk/gui.c b/gtk/gui.c index 7de448c0b..9cd89e627 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -33,13 +33,13 @@ #include #include #include -#include #include #include #include #include "content/content.h" #include "content/fetch.h" +#include "content/fetchers.h" #include "content/fetchers/curl.h" #include "content/fetchers/resource.h" #include "content/hlcache.h" @@ -485,51 +485,42 @@ static bool nslog_stream_configure(FILE *fptr) static void nsgtk_poll(bool active) { - CURLMcode code; fd_set read_fd_set, write_fd_set, exc_fd_set; int max_fd; GPollFD *fd_list[1000]; unsigned int fd_count = 0; bool block = true; + fetcher_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd); + for (int i = 0; i <= max_fd; i++) { + if (FD_ISSET(i, &read_fd_set)) { + GPollFD *fd = malloc(sizeof *fd); + fd->fd = i; + fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; + g_main_context_add_poll(0, fd, 0); + fd_list[fd_count++] = fd; + } + if (FD_ISSET(i, &write_fd_set)) { + GPollFD *fd = malloc(sizeof *fd); + fd->fd = i; + fd->events = G_IO_OUT | G_IO_ERR; + g_main_context_add_poll(0, fd, 0); + fd_list[fd_count++] = fd; + } + if (FD_ISSET(i, &exc_fd_set)) { + GPollFD *fd = malloc(sizeof *fd); + fd->fd = i; + fd->events = G_IO_ERR; + g_main_context_add_poll(0, fd, 0); + fd_list[fd_count++] = fd; + } + } + schedule_run(); - if (browser_reformat_pending) + if (browser_reformat_pending) { + nsgtk_window_process_reformats(); block = false; - - if (active) { - FD_ZERO(&read_fd_set); - FD_ZERO(&write_fd_set); - FD_ZERO(&exc_fd_set); - code = curl_multi_fdset(fetch_curl_multi, - &read_fd_set, - &write_fd_set, - &exc_fd_set, - &max_fd); - assert(code == CURLM_OK); - for (int i = 0; i <= max_fd; i++) { - if (FD_ISSET(i, &read_fd_set)) { - GPollFD *fd = malloc(sizeof *fd); - fd->fd = i; - fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; - g_main_context_add_poll(0, fd, 0); - fd_list[fd_count++] = fd; - } - if (FD_ISSET(i, &write_fd_set)) { - GPollFD *fd = malloc(sizeof *fd); - fd->fd = i; - fd->events = G_IO_OUT | G_IO_ERR; - g_main_context_add_poll(0, fd, 0); - fd_list[fd_count++] = fd; - } - if (FD_ISSET(i, &exc_fd_set)) { - GPollFD *fd = malloc(sizeof *fd); - fd->fd = i; - fd->events = G_IO_ERR; - g_main_context_add_poll(0, fd, 0); - fd_list[fd_count++] = fd; - } - } } gtk_main_iteration_do(block); @@ -539,10 +530,6 @@ static void nsgtk_poll(bool active) free(fd_list[i]); } - schedule_run(); - - if (browser_reformat_pending) - nsgtk_window_process_reformats(); } diff --git a/monkey/poll.c b/monkey/poll.c index 414d458bd..d5b49f059 100644 --- a/monkey/poll.c +++ b/monkey/poll.c @@ -22,7 +22,7 @@ #include "desktop/gui.h" #include "monkey/schedule.h" #include "monkey/browser.h" -#include "content/fetchers/curl.h" +#include "content/fetchers.h" #include "monkey/dispatch.h" #include "monkey/poll.h" @@ -90,58 +90,48 @@ monkey_prepare_input(void) void monkey_poll(bool active) { - CURLMcode code; fd_set read_fd_set, write_fd_set, exc_fd_set; int max_fd; GPollFD *fd_list[1000]; unsigned int fd_count = 0; bool block = true; - + + fetcher_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd); + for (int i = 0; i <= max_fd; i++) { + if (FD_ISSET(i, &read_fd_set)) { + GPollFD *fd = malloc(sizeof *fd); + fd->fd = i; + fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; + g_main_context_add_poll(0, fd, 0); + fd_list[fd_count++] = fd; + LOG(("Want to read %d", i)); + } + if (FD_ISSET(i, &write_fd_set)) { + GPollFD *fd = malloc(sizeof *fd); + fd->fd = i; + fd->events = G_IO_OUT | G_IO_ERR; + g_main_context_add_poll(0, fd, 0); + fd_list[fd_count++] = fd; + LOG(("Want to write %d", i)); + } + if (FD_ISSET(i, &exc_fd_set)) { + GPollFD *fd = malloc(sizeof *fd); + fd->fd = i; + fd->events = G_IO_ERR; + g_main_context_add_poll(0, fd, 0); + fd_list[fd_count++] = fd; + LOG(("Want to check %d", i)); + } + } + schedule_run(); - if (browser_reformat_pending) + if (browser_reformat_pending) { + monkey_window_process_reformats(); block = false; - - if (active) { - FD_ZERO(&read_fd_set); - FD_ZERO(&write_fd_set); - FD_ZERO(&exc_fd_set); - code = curl_multi_fdset(fetch_curl_multi, - &read_fd_set, - &write_fd_set, - &exc_fd_set, - &max_fd); - assert(code == CURLM_OK); - LOG(("maxfd from curl is %d", max_fd)); - for (int i = 0; i <= max_fd; i++) { - if (FD_ISSET(i, &read_fd_set)) { - GPollFD *fd = malloc(sizeof *fd); - fd->fd = i; - fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; - g_main_context_add_poll(0, fd, 0); - fd_list[fd_count++] = fd; - LOG(("Want to read %d", i)); - } - if (FD_ISSET(i, &write_fd_set)) { - GPollFD *fd = malloc(sizeof *fd); - fd->fd = i; - fd->events = G_IO_OUT | G_IO_ERR; - g_main_context_add_poll(0, fd, 0); - fd_list[fd_count++] = fd; - LOG(("Want to write %d", i)); - } - if (FD_ISSET(i, &exc_fd_set)) { - GPollFD *fd = malloc(sizeof *fd); - fd->fd = i; - fd->events = G_IO_ERR; - g_main_context_add_poll(0, fd, 0); - fd_list[fd_count++] = fd; - LOG(("Want to check %d", i)); - } - } } - - LOG(("Iterate %sactive %sblocking", active?"":"in", block?"":"non-")); + + LOG(("Iterate %sblocking", block?"":"non-")); if (block) { fprintf(stdout, "GENERIC POLL BLOCKING\n"); } @@ -152,9 +142,5 @@ monkey_poll(bool active) free(fd_list[i]); } - schedule_run(); - - if (browser_reformat_pending) - monkey_window_process_reformats(); } diff --git a/riscos/gui.c b/riscos/gui.c index 09f254bb4..00f6ebc11 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -1852,24 +1852,19 @@ static void ro_gui_handle_event(wimp_event_no event, wimp_block *block) /** - * Poll the OS for events (RISC OS). - * - * \param active return as soon as possible + * Poll the RISC OS wimp for events. */ static void riscos_poll(bool active) { wimp_event_no event; wimp_block block; - const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN | - wimp_SAVE_FP; + const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN | wimp_SAVE_FP; os_t track_poll_offset; /* Poll wimp. */ xhourglass_off(); track_poll_offset = ro_mouse_poll_interval(); - if (active) { - event = wimp_poll(mask, &block, 0); - } else if (sched_active || (track_poll_offset > 0) || + if (sched_active || (track_poll_offset > 0) || browser_reformat_pending) { os_t t = os_read_monotonic_time(); diff --git a/windows/gui.c b/windows/gui.c index 21eff0ef4..824abade7 100644 --- a/windows/gui.c +++ b/windows/gui.c @@ -107,10 +107,6 @@ static void win32_poll(bool active) /* run the scheduler and discover how long to wait for the next event */ timeout = schedule_run(); - /* if active set timeout so message is not waited for */ - if (active) - timeout = 0; - if (timeout == 0) { bRet = PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE); } else { @@ -128,7 +124,6 @@ static void win32_poll(bool active) } } - if (bRet > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); -- cgit v1.2.3