2 * reactos PoQueueShutdownWorkItem() implementation by libcaptive
3 * Copyright (C) 2002 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 /* no reactos prototype for PoQueueShutdownWorkItem() */
23 #include "captive/ldr.h" /* self; for captive_PoQueueShutdownWorkItem_hooklist_invoke() */
24 #include <glib/gmessages.h>
25 #include <glib/ghook.h>
26 #include "reactos/ddk/extypes.h" /* for WORK_QUEUE_ITEM */
27 #include "captive/macros.h"
30 static GHookList captive_PoQueueShutdownWorkItem_hooklist;
33 static void captive_PoQueueShutdownWorkItem_hooklist_init(void)
35 if (captive_PoQueueShutdownWorkItem_hooklist.is_setup)
38 g_hook_list_init(&captive_PoQueueShutdownWorkItem_hooklist,sizeof(GHook));
42 void captive_PoQueueShutdownWorkItem_hooklist_invoke(void)
44 captive_PoQueueShutdownWorkItem_hooklist_init();
46 g_hook_list_invoke(&captive_PoQueueShutdownWorkItem_hooklist,
47 FALSE); /* may_recurse */
48 g_hook_list_clear(&captive_PoQueueShutdownWorkItem_hooklist);
52 struct captive_work_queue_item {
53 PWORKER_THREAD_ROUTINE WorkerRoutine;
57 static void PoQueueShutdownWorkItem_func(struct captive_work_queue_item *captive_work_queue_item /* data */)
59 g_return_if_fail(captive_work_queue_item!=NULL);
61 /* typedef VOID CAPTIVE_STDCALL (*PWORKER_THREAD_ROUTINE)(IN PVOID Context); */
63 captive_stdcall_call_4((CaptiveStdCallFunc4)captive_work_queue_item->WorkerRoutine,
64 captive_work_queue_item->Parameter); /* Context */
66 g_free(captive_work_queue_item);
69 NTSTATUS PoQueueShutdownWorkItem(IN PWORK_QUEUE_ITEM WorkItem)
72 struct captive_work_queue_item *captive_work_queue_item;
74 g_return_val_if_fail(WorkItem!=NULL,STATUS_INVALID_PARAMETER);
75 g_return_val_if_fail(WorkItem->WorkerRoutine!=NULL,STATUS_INVALID_PARAMETER);
77 captive_PoQueueShutdownWorkItem_hooklist_init();
79 captive_new(captive_work_queue_item);
80 captive_work_queue_item->WorkerRoutine=WorkItem->WorkerRoutine;
81 captive_work_queue_item->Parameter=WorkItem->Parameter;
83 /* FIXME: Should we check for func/data dupes? Are they permitted by W32? */
85 ghook=g_hook_alloc(&captive_PoQueueShutdownWorkItem_hooklist);
86 ghook->func=PoQueueShutdownWorkItem_func;
87 ghook->data=captive_work_queue_item;
88 g_hook_append(&captive_PoQueueShutdownWorkItem_hooklist,ghook);
90 return STATUS_SUCCESS;