mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-17 01:33:16 +03:00
convert all frontends to scheduled fetch operation
This commit is contained in:
parent
1b7aa7ffe5
commit
8944edd649
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
34
beos/gui.cpp
34
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
|
||||
/* get any active fetcher fd */
|
||||
fetcher_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd);
|
||||
|
||||
/* run the scheduler */
|
||||
schedule_run();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
69
gtk/gui.c
69
gtk/gui.c
@ -33,13 +33,13 @@
|
||||
#include <sys/select.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <curl/curl.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
schedule_run();
|
||||
|
||||
if (browser_reformat_pending)
|
||||
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));
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
LOG(("Iterate %sactive %sblocking", active?"":"in", block?"":"non-"));
|
||||
|
||||
schedule_run();
|
||||
|
||||
if (browser_reformat_pending) {
|
||||
monkey_window_process_reformats();
|
||||
block = false;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
11
riscos/gui.c
11
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();
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user