Commit 94fcaad7 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use standard list to store task queue.

parent 0c2b684c
...@@ -1018,7 +1018,7 @@ struct task_t { ...@@ -1018,7 +1018,7 @@ struct task_t {
LONG target_magic; LONG target_magic;
task_proc_t proc; task_proc_t proc;
task_proc_t destr; task_proc_t destr;
struct task_t *next; struct list entry;
}; };
typedef struct { typedef struct {
...@@ -1028,8 +1028,7 @@ typedef struct { ...@@ -1028,8 +1028,7 @@ typedef struct {
typedef struct { typedef struct {
HWND thread_hwnd; HWND thread_hwnd;
task_t *task_queue_head; struct list task_list;
task_t *task_queue_tail;
struct list timer_list; struct list timer_list;
} thread_data_t; } thread_data_t;
......
...@@ -69,14 +69,8 @@ HRESULT push_task(task_t *task, task_proc_t proc, task_proc_t destr, LONG magic) ...@@ -69,14 +69,8 @@ HRESULT push_task(task_t *task, task_proc_t proc, task_proc_t destr, LONG magic)
task->target_magic = magic; task->target_magic = magic;
task->proc = proc; task->proc = proc;
task->destr = destr ? destr : default_task_destr; task->destr = destr ? destr : default_task_destr;
task->next = NULL;
if(thread_data->task_queue_tail) list_add_tail(&thread_data->task_list, &task->entry);
thread_data->task_queue_tail->next = task;
else
thread_data->task_queue_head = task;
thread_data->task_queue_tail = task;
PostMessageW(thread_data->thread_hwnd, WM_PROCESSTASK, 0, 0); PostMessageW(thread_data->thread_hwnd, WM_PROCESSTASK, 0, 0);
return S_OK; return S_OK;
...@@ -91,14 +85,11 @@ static task_t *pop_task(void) ...@@ -91,14 +85,11 @@ static task_t *pop_task(void)
if(!thread_data) if(!thread_data)
return NULL; return NULL;
task = thread_data->task_queue_head; if(list_empty(&thread_data->task_list))
if(!task)
return NULL; return NULL;
thread_data->task_queue_head = task->next; task = LIST_ENTRY(thread_data->task_list.next, task_t, entry);
if(!thread_data->task_queue_head) list_remove(&task->entry);
thread_data->task_queue_tail = NULL;
return task; return task;
} }
...@@ -116,7 +107,7 @@ void remove_target_tasks(LONG target) ...@@ -116,7 +107,7 @@ void remove_target_tasks(LONG target)
thread_data_t *thread_data = get_thread_data(FALSE); thread_data_t *thread_data = get_thread_data(FALSE);
struct list *liter, *ltmp; struct list *liter, *ltmp;
task_timer_t *timer; task_timer_t *timer;
task_t *iter, *tmp; task_t *task;
if(!thread_data) if(!thread_data)
return; return;
...@@ -134,20 +125,12 @@ void remove_target_tasks(LONG target) ...@@ -134,20 +125,12 @@ void remove_target_tasks(LONG target)
SetTimer(thread_data->thread_hwnd, TIMER_ID, max( (int)(timer->time - tc), 0 ), NULL); SetTimer(thread_data->thread_hwnd, TIMER_ID, max( (int)(timer->time - tc), 0 ), NULL);
} }
while(thread_data->task_queue_head && thread_data->task_queue_head->target_magic == target) { LIST_FOR_EACH_SAFE(liter, ltmp, &thread_data->task_list) {
iter = pop_task(); task = LIST_ENTRY(liter, task_t, entry);
iter->destr(iter); if(task->target_magic == target) {
} list_remove(&task->entry);
task->destr(task);
for(iter = thread_data->task_queue_head; iter; iter = iter->next) {
while(iter->next && iter->next->target_magic == target) {
tmp = iter->next;
iter->next = tmp->next;
tmp->destr(tmp);
} }
if(!iter->next)
thread_data->task_queue_tail = iter;
} }
} }
...@@ -390,6 +373,7 @@ thread_data_t *get_thread_data(BOOL create) ...@@ -390,6 +373,7 @@ thread_data_t *get_thread_data(BOOL create)
return NULL; return NULL;
TlsSetValue(mshtml_tls, thread_data); TlsSetValue(mshtml_tls, thread_data);
list_init(&thread_data->task_list);
list_init(&thread_data->timer_list); list_init(&thread_data->timer_list);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment