summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiguel <miguel@localhost>2018-03-12 19:24:38 +0100
committermiguel <miguel@localhost>2018-03-12 19:24:38 +0100
commite35799ee201af5d1fe734598f1ef9509d441fc9f (patch)
treea7868515b6585de10fb2d3669b7b298149461833
parentae771563d3ceea2c237edf256fb37cc51a787818 (diff)
adding threading stuff
-rw-r--r--surf-webext-dom.c21
1 files changed, 21 insertions, 0 deletions
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 <sys/shm.h>
#include <errno.h>
#include <string.h>
+#include <pthread.h>
+
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