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>
28 static gboolean ExQueueWorkItem_idlefunc(WORK_QUEUE_ITEM *WorkItem /* data */)
30 g_return_val_if_fail(WorkItem!=NULL,FALSE); /* false=>remove-me */
31 g_return_val_if_fail(WorkItem->Routine!=NULL,FALSE); /* false=>remove-me */
33 /* typedef VOID STDCALL_FUNC (*PWORKER_THREAD_ROUTINE)(PVOID Parameter); */
35 (*WorkItem->Routine)(WorkItem->Context);
36 WorkItem->Routine=NULL; /* request is no longer pending */
37 return FALSE; /* remove-me */
42 * @WorkItem: Initialized structure of #WORK_QUEUE_ITEM to be initialize.
43 * %NULL value is forbidden.
44 * @QueueType: Queue priority.
46 * Inserts a work item in a queue for one of the system worker threads to
47 * process. It will be processed through g_idle_add_full() with priority
48 * range %G_PRIORITY_DEFAULT+10 ... %G_PRIORITY_DEFAULT+30.
50 * FIXME: @WorkItem is required by libcaptive to remain valid until invocation.
53 VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,WORK_QUEUE_TYPE QueueType)
57 g_return_if_fail(WorkItem!=NULL);
58 g_return_if_fail(WorkItem->Routine!=NULL);
61 case DelayedWorkQueue:
62 priority=G_PRIORITY_DEFAULT+30; /* positive towards G_PRIORITY_HIGH_IDLE */
64 case CriticalWorkQueue:
65 priority=G_PRIORITY_DEFAULT+20; /* positive towards G_PRIORITY_HIGH_IDLE */
67 case HyperCriticalWorkQueue:
68 priority=G_PRIORITY_DEFAULT+10; /* positive towards G_PRIORITY_HIGH_IDLE */
71 g_assert_not_reached();
72 priority=G_PRIORITY_DEFAULT;
76 priority, /* priority */
77 (GSourceFunc)ExQueueWorkItem_idlefunc, /* function */