Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lexborisov/perl-html-myhtml.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorlex <lexinhell@gmail.com>2016-03-28 23:44:04 +0300
committerlex <lexinhell@gmail.com>2016-03-28 23:44:04 +0300
commit198ddf7de979bb88d0c9191fa41b4fd0f88db6c5 (patch)
treebf93bd9a397c04727e2a1dad3b17c90cb4a1ddd0 /source
parent79ed21801adb4e80b2c904a5c7573895845b0e08 (diff)
Fixes for OS Windows. Speed UP for OS Windows
Diffstat (limited to 'source')
-rw-r--r--source/myhtml/thread.c9
-rw-r--r--source/myhtml/token.c3
-rw-r--r--source/myhtml/tree.c4
-rw-r--r--source/myhtml/tree.h2
4 files changed, 9 insertions, 9 deletions
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;