From e35799ee201af5d1fe734598f1ef9509d441fc9f Mon Sep 17 00:00:00 2001 From: miguel Date: Mon, 12 Mar 2018 19:24:38 +0100 Subject: adding threading stuff --- surf-webext-dom.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/surf-webext-dom.c b/surf-webext-dom.c index 31e1308..2f18806 100644 --- a/surf-webext-dom.c +++ b/surf-webext-dom.c @@ -31,15 +31,35 @@ #include #include #include +#include + bool str_prefix(const char *str, const char *pre); +static int call=0; + +void* perform_work(void* argument) { + int passed_in_value; + + passed_in_value = *((int*) argument); + for(int i=0;i<10;i++) + { + printf("Hello World! It's me, thread with argument %d!\n", passed_in_value); + sleep(1); + } + return NULL; +} + void document_loaded_callback (WebKitWebPage *web_page, GPtrArray *elements, GVariant *user_data) { + pthread_t thread; + g_print("called counter: %i\n",call++); + pthread_create(&thread, NULL, perform_work, &call); + // TODO: g_free where appropriate !! // TODO: allow focus on input boxes/forms // TODO: Put this somehwere else? (but I dislike #defines) @@ -51,6 +71,7 @@ document_loaded_callback (WebKitWebPage *web_page, // get html doc WebKitDOMHTMLDocument *doc = webkit_web_page_get_dom_document(web_page); + if(!WEBKIT_DOM_IS_HTML_DOCUMENT(doc))return; // get url -- cgit v1.2.3