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 (*WorkItem_copy->WorkerRoutine)(WorkItem_copy->Parameter);
37 g_free(WorkItem_copy);
39 return FALSE; /* remove-me */
44 * @WorkItem: Initialized structure of #WORK_QUEUE_ITEM to enqueue.
45 * %NULL value is forbidden.
46 * @QueueType: Queue priority.
48 * Inserts a work item in a queue for one of the system worker threads to
49 * process. It will be processed through g_idle_add_full() with priority
50 * range %G_PRIORITY_DEFAULT+10 ... %G_PRIORITY_DEFAULT+30.
52 * @WorkItem memory address space can be freed even before its function invocation
53 * (required by ntfs.sys).
55 VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,WORK_QUEUE_TYPE QueueType)
58 WORK_QUEUE_ITEM *WorkItem_copy;
60 g_return_if_fail(WorkItem!=NULL);
61 g_return_if_fail(WorkItem->WorkerRoutine!=NULL);
64 case DelayedWorkQueue:
65 priority=G_PRIORITY_DEFAULT+30; /* positive towards G_PRIORITY_HIGH_IDLE */
67 case CriticalWorkQueue:
68 priority=G_PRIORITY_DEFAULT+20; /* positive towards G_PRIORITY_HIGH_IDLE */
70 case HyperCriticalWorkQueue:
71 priority=G_PRIORITY_DEFAULT+10; /* positive towards G_PRIORITY_HIGH_IDLE */
74 g_assert_not_reached();
75 priority=G_PRIORITY_DEFAULT;
78 captive_memdup(WorkItem_copy,WorkItem);
80 priority, /* priority */
81 (GSourceFunc)ExQueueWorkItem_idlefunc, /* function */
82 WorkItem_copy, /* data */