diff options
author | lex <lexinhell@gmail.com> | 2016-03-28 23:44:04 +0300 |
---|---|---|
committer | lex <lexinhell@gmail.com> | 2016-03-28 23:44:04 +0300 |
commit | 198ddf7de979bb88d0c9191fa41b4fd0f88db6c5 (patch) | |
tree | bf93bd9a397c04727e2a1dad3b17c90cb4a1ddd0 | |
parent | 79ed21801adb4e80b2c904a5c7573895845b0e08 (diff) |
Fixes for OS Windows. Speed UP for OS Windows
-rw-r--r-- | Changes | 3 | ||||
-rwxr-xr-x | MyHTML.pm | 2 | ||||
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | source/myhtml/thread.c | 9 | ||||
-rw-r--r-- | source/myhtml/token.c | 3 | ||||
-rw-r--r-- | source/myhtml/tree.c | 4 | ||||
-rw-r--r-- | source/myhtml/tree.h | 2 |
7 files changed, 20 insertions, 10 deletions
@@ -1,3 +1,6 @@ +0.32 Mon Mar 28 2016 23:41:03 GMT+0300 + Fisex for OS Windows. Speed UP for OS Windows + 0.31 Mon Mar 28 2016 16:15:03 GMT+0300 Build for Windows Now memory is used more wisely. @@ -22,7 +22,7 @@ use strict; use vars qw($AUTOLOAD $VERSION $ABSTRACT @ISA @EXPORT); BEGIN { - $VERSION = 0.31; + $VERSION = 0.32; $ABSTRACT = "Fast HTML Parser using Threads with no outside dependencies"; @ISA = qw(Exporter DynaLoader); @@ -19,6 +19,13 @@ Just follow the usual procedure: make test make install +For Windows OS (for Strawberry Perl (http://strawberryperl.com/)) + + perl Makefile.PL + dmake + dmake test + dmake install + METHODS diff --git a/source/myhtml/thread.c b/source/myhtml/thread.c index 38a6a01..60a8681 100644 --- a/source/myhtml/thread.c +++ b/source/myhtml/thread.c @@ -72,13 +72,13 @@ myhtml_status_t myhtml_hread_sem_create(mythread_t *mythread, mythread_context_t { ctx->sem_name = calloc(1024, sizeof(wchar_t)); - sprintf(ctx->sem_name, "Global/%s%zus%zup%zu", MyTHREAD_SEM_NAME, prefix_id, ctx->id, (size_t)mythread); + sprintf(ctx->sem_name, "Global/%s%lus%lup%lu", MyTHREAD_SEM_NAME, prefix_id, ctx->id, (size_t)mythread); ctx->sem_name_size = strlen(ctx->sem_name); ctx->sem = CreateSemaphore(NULL, // default security attributes 0, // initial count - 1, // maximum count + 100, // maximum count ctx->sem_name); // named semaphore if (ctx->sem == NULL) { @@ -94,9 +94,7 @@ myhtml_status_t myhtml_hread_sem_create(mythread_t *mythread, mythread_context_t myhtml_status_t myhtml_hread_sem_post(mythread_t *mythread, mythread_context_t *ctx) { - if(!ReleaseSemaphore(ctx->sem, 1, NULL)) { - return MyHTML_STATUS_OK; - } + while(!ReleaseSemaphore(ctx->sem, 1, NULL)) {} return MyHTML_STATUS_OK; } @@ -118,6 +116,7 @@ myhtml_status_t myhtml_hread_sem_close(mythread_t *mythread, mythread_context_t void myhtml_thread_nanosleep(const struct timespec *tomeout) { + Sleep(0); } #else /* defined(IS_OS_WINDOWS) */ diff --git a/source/myhtml/token.c b/source/myhtml/token.c index 428c672..1ad370d 100644 --- a/source/myhtml/token.c +++ b/source/myhtml/token.c @@ -171,7 +171,8 @@ void myhtml_token_attr_clean(myhtml_token_attr_t* attr) void myhtml_token_node_wait_for_done(myhtml_token_node_t* node) { - while((node->type & MyHTML_TOKEN_TYPE_DONE) == 0) {} + const struct timespec timeout = {0, 10000}; + while((node->type & MyHTML_TOKEN_TYPE_DONE) == 0) {myhtml_thread_nanosleep(&timeout);} } myhtml_token_node_t * myhtml_token_node_clone(myhtml_token_t* token, myhtml_token_node_t* node, size_t token_thread_idx, size_t attr_thread_idx) diff --git a/source/myhtml/tree.c b/source/myhtml/tree.c index 50fa418..d342a16 100644 --- a/source/myhtml/tree.c +++ b/source/myhtml/tree.c @@ -2644,8 +2644,8 @@ void myhtml_tree_wait_for_last_done_token(myhtml_tree_t* tree, myhtml_token_node { #ifndef MyHTML_BUILD_WITHOUT_THREADS - const struct timespec tomeout = {0, 1000}; - while(tree->token_last_done != token_for_wait) {myhtml_thread_nanosleep(&tomeout);} + myhtml_token_node_t* volatile token_last_done = tree->token_last_done; + while(token_last_done != token_for_wait) {token_last_done = tree->token_last_done;} #endif } diff --git a/source/myhtml/tree.h b/source/myhtml/tree.h index a58f1ce..7cea4c3 100644 --- a/source/myhtml/tree.h +++ b/source/myhtml/tree.h @@ -199,7 +199,7 @@ struct myhtml_tree { myhtml_tree_insertion_list_t* template_insertion; myhtml_async_args_t* async_args; myhtml_tree_temp_stream_t* temp_stream; - volatile myhtml_token_node_t* token_last_done; + myhtml_token_node_t* volatile token_last_done; // for detect namespace out of tree builder myhtml_token_node_t* token_namespace; |