2 * reactos WORK_QUEUE_ITEM handling by libcaptive
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "reactos/ddk/exfuncs.h" /* self */
23 #include <glib/gmessages.h>
24 #include "reactos/ddk/extypes.h" /* for WORK_QUEUE_ITEM */
25 #include <glib/gmain.h>
26 #include "captive/macros.h"
29 static gboolean ExQueueWorkItem_idlefunc(WORK_QUEUE_ITEM *WorkItem_copy /* data */)
31 g_return_val_if_fail(WorkItem_copy!=NULL,FALSE); /* false=>remove-me */
32 g_return_val_if_fail(WorkItem_copy->WorkerRoutine!=NULL,FALSE); /* false=>remove-me */
34 /* typedef VOID STDCALL_FUNC (*PWORKER_THREAD_ROUTINE)(PVOID Parameter); */
36 captive_stdcall_call_4((CaptiveStdCallFunc4)WorkItem_copy->WorkerRoutine,
37 WorkItem_copy->Parameter); /* Parameter */
38 g_free(WorkItem_copy);
40 return FALSE; /* remove-me */
45 * @WorkItem: Initialized structure of #WORK_QUEUE_ITEM to enqueue.
46 * %NULL value is forbidden.
47 * @QueueType: Queue priority.
49 * Inserts a work item in a queue for one of the system worker threads to
50 * process. It will be processed through g_idle_add_full() with priority
51 * range %G_PRIORITY_DEFAULT+10 ... %G_PRIORITY_DEFAULT+30.
53 * @WorkItem memory address space can be freed even before its function invocation
54 * (required by ntfs.sys).
56 VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,WORK_QUEUE_TYPE QueueType)
59 WORK_QUEUE_ITEM *WorkItem_copy;
61 g_return_if_fail(WorkItem!=NULL);
62 g_return_if_fail(WorkItem->WorkerRoutine!=NULL);
65 case DelayedWorkQueue:
66 priority=G_PRIORITY_DEFAULT+30; /* positive towards G_PRIORITY_HIGH_IDLE */
68 case CriticalWorkQueue:
69 priority=G_PRIORITY_DEFAULT+20; /* positive towards G_PRIORITY_HIGH_IDLE */
71 case HyperCriticalWorkQueue:
72 priority=G_PRIORITY_DEFAULT+10; /* positive towards G_PRIORITY_HIGH_IDLE */
75 g_assert_not_reached();
76 priority=G_PRIORITY_DEFAULT;
79 captive_memdup(WorkItem_copy,WorkItem);
81 priority, /* priority */
82 (GSourceFunc)ExQueueWorkItem_idlefunc, /* function */
83 WorkItem_copy, /* data */