ReactOS 0.4.17-dev-934-g091855f
threadpool.c
Go to the documentation of this file.
1/*
2 * DirectPlay8 ThreadPool
3 *
4 * Copyright 2004 Raphael Junqueira
5 * Copyright 2008 Alexander N. Sørnes <alex@thehandofagony.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 *
21 */
22
23
24#include <stdarg.h>
25
26#define COBJMACROS
27#include "windef.h"
28#include "winbase.h"
29#include "wingdi.h"
30#include "winuser.h"
31#include "objbase.h"
32#include "wine/debug.h"
33
34#include "dpnet_private.h"
35
37
41
42static inline IDirectPlay8ThreadPoolImpl *impl_from_IDirectPlay8ThreadPool(IDirectPlay8ThreadPool *iface)
43{
44 return CONTAINING_RECORD(iface, IDirectPlay8ThreadPoolImpl, IDirectPlay8ThreadPool_iface);
45}
46
47/* IUnknown interface follows */
48static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_QueryInterface(IDirectPlay8ThreadPool *iface,
49 REFIID riid, void **ret_iface)
50{
51 if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectPlay8ThreadPool))
52 {
54 *ret_iface = iface;
55 return S_OK;
56 }
57
58 WARN("(%p)->(%s,%p): not found\n", iface, debugstr_guid(riid), ret_iface);
59 return E_NOINTERFACE;
60}
61
62static ULONG WINAPI IDirectPlay8ThreadPoolImpl_AddRef(IDirectPlay8ThreadPool *iface)
63{
65 ULONG RefCount = InterlockedIncrement(&This->ref);
66
67 return RefCount;
68}
69
70static ULONG WINAPI IDirectPlay8ThreadPoolImpl_Release(IDirectPlay8ThreadPool *iface)
71{
73 ULONG RefCount = InterlockedDecrement(&This->ref);
74
75 if(!RefCount)
77
78 return RefCount;
79}
80
81/* IDirectPlay8ThreadPool interface follows */
82static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Initialize(IDirectPlay8ThreadPool *iface,
83 void * const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags)
84{
86
87 TRACE("(%p)->(%p,%p,%lx)\n", This, pvUserContext, pfn, dwFlags);
88
89 if(!pfn)
91
94
97 threadpool_usercontext = pvUserContext;
98
99 return DPN_OK;
100}
101
102static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Close(IDirectPlay8ThreadPool *iface,
103 const DWORD dwFlags)
104{
106
107 FIXME("(%p)->(%lx)\n", This, dwFlags);
108
111
113
114 return DPN_OK;
115}
116
117static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_GetThreadCount(IDirectPlay8ThreadPool *iface,
118 const DWORD dwProcessorNum, DWORD * const pdwNumThreads, const DWORD dwFlags)
119{
120 FIXME("(%p)->(%lx,%p,%lx): stub\n", iface, dwProcessorNum, pdwNumThreads, dwFlags);
121 *pdwNumThreads = 0;
122 return DPN_OK;
123}
124
125static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_SetThreadCount(IDirectPlay8ThreadPool *iface,
126 const DWORD dwProcessorNum, const DWORD dwNumThreads, const DWORD dwFlags)
127{
128 FIXME("(%p)->(%lx,%lx,%lx): stub\n", iface, dwProcessorNum, dwNumThreads, dwFlags);
129 return DPN_OK;
130}
131
132static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_DoWork(IDirectPlay8ThreadPool *iface,
133 const DWORD dwAllowedTimeSlice, const DWORD dwFlags)
134{
135 static BOOL Run = FALSE;
136
137 if(!Run)
138 FIXME("(%p)->(%lx,%lx): stub\n", iface, dwAllowedTimeSlice, dwFlags);
139
140 Run = TRUE;
141
142 return DPN_OK;
143}
144
145static const IDirectPlay8ThreadPoolVtbl DirectPlay8ThreadPool_Vtbl =
146{
155};
156
157HRESULT DPNET_CreateDirectPlay8ThreadPool(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj)
158{
160
162
163 if(Client == NULL)
164 {
165 *ppobj = NULL;
166 WARN("Not enough memory\n");
167 return E_OUTOFMEMORY;
168 }
169
170 Client->IDirectPlay8ThreadPool_iface.lpVtbl = &DirectPlay8ThreadPool_Vtbl;
171 Client->ref = 0;
172
173 return IDirectPlay8ThreadPoolImpl_QueryInterface(&Client->IDirectPlay8ThreadPool_iface, riid,
174 ppobj);
175}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static LPVOID LPUNKNOWN
Definition: dinput.c:53
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_QueryInterface(IDirectPlay8ThreadPool *iface, REFIID riid, void **ret_iface)
Definition: threadpool.c:48
static ULONG WINAPI IDirectPlay8ThreadPoolImpl_Release(IDirectPlay8ThreadPool *iface)
Definition: threadpool.c:70
static DWORD threadpool_flags
Definition: threadpool.c:39
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_GetThreadCount(IDirectPlay8ThreadPool *iface, const DWORD dwProcessorNum, DWORD *const pdwNumThreads, const DWORD dwFlags)
Definition: threadpool.c:117
static ULONG WINAPI IDirectPlay8ThreadPoolImpl_AddRef(IDirectPlay8ThreadPool *iface)
Definition: threadpool.c:62
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Initialize(IDirectPlay8ThreadPool *iface, void *const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags)
Definition: threadpool.c:82
static PFNDPNMESSAGEHANDLER threadpool_msghandler
Definition: threadpool.c:38
static void * threadpool_usercontext
Definition: threadpool.c:40
HRESULT DPNET_CreateDirectPlay8ThreadPool(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj)
Definition: threadpool.c:157
static const IDirectPlay8ThreadPoolVtbl DirectPlay8ThreadPool_Vtbl
Definition: threadpool.c:145
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Close(IDirectPlay8ThreadPool *iface, const DWORD dwFlags)
Definition: threadpool.c:102
static IDirectPlay8ThreadPoolImpl * impl_from_IDirectPlay8ThreadPool(IDirectPlay8ThreadPool *iface)
Definition: threadpool.c:42
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_DoWork(IDirectPlay8ThreadPool *iface, const DWORD dwAllowedTimeSlice, const DWORD dwFlags)
Definition: threadpool.c:132
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_SetThreadCount(IDirectPlay8ThreadPool *iface, const DWORD dwProcessorNum, const DWORD dwNumThreads, const DWORD dwFlags)
Definition: threadpool.c:125
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define DPNERR_ALREADYINITIALIZED
Definition: dplay8.h:88
HRESULT(WINAPI * PFNDPNMESSAGEHANDLER)(PVOID, DWORD, PVOID)
Definition: dplay8.h:30
#define DPNERR_INVALIDPARAM
Definition: dplay8.h:77
#define DPN_OK
Definition: dplay8.h:75
#define IDirectPlay8ThreadPool_AddRef(p)
Definition: dplay8.h:929
#define DPNERR_UNINITIALIZED
Definition: dplay8.h:146
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define TRACE(s)
Definition: solgame.cpp:4
Definition: client.c:31
LONG ref
Definition: client.c:37
Definition: bidi.c:435
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:3479