user32: Uppercase the RawInput device names sans the GUID.
[wine.git] / dlls / dpnet / threadpool.c
blob37dda49e84d23c4734857268276e14371b9a86f3
1 /*
2 * DirectPlay8 ThreadPool
4 * Copyright 2004 Raphael Junqueira
5 * Copyright 2008 Alexander N. Sørnes <alex@thehandofagony.com>
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.
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.
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
24 #include <stdarg.h>
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"
34 #include "dpnet_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
38 static PFNDPNMESSAGEHANDLER threadpool_msghandler = NULL;
39 static DWORD threadpool_flags = 0;
40 static void *threadpool_usercontext = NULL;
42 static inline IDirectPlay8ThreadPoolImpl *impl_from_IDirectPlay8ThreadPool(IDirectPlay8ThreadPool *iface)
44 return CONTAINING_RECORD(iface, IDirectPlay8ThreadPoolImpl, IDirectPlay8ThreadPool_iface);
47 /* IUnknown interface follows */
48 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_QueryInterface(IDirectPlay8ThreadPool *iface,
49 REFIID riid, void **ret_iface)
51 if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectPlay8ThreadPool))
53 IDirectPlay8ThreadPool_AddRef(iface);
54 *ret_iface = iface;
55 return S_OK;
58 WARN("(%p)->(%s,%p): not found\n", iface, debugstr_guid(riid), ret_iface);
59 return E_NOINTERFACE;
62 static ULONG WINAPI IDirectPlay8ThreadPoolImpl_AddRef(IDirectPlay8ThreadPool *iface)
64 IDirectPlay8ThreadPoolImpl* This = impl_from_IDirectPlay8ThreadPool(iface);
65 ULONG RefCount = InterlockedIncrement(&This->ref);
67 return RefCount;
70 static ULONG WINAPI IDirectPlay8ThreadPoolImpl_Release(IDirectPlay8ThreadPool *iface)
72 IDirectPlay8ThreadPoolImpl* This = impl_from_IDirectPlay8ThreadPool(iface);
73 ULONG RefCount = InterlockedDecrement(&This->ref);
75 if(!RefCount)
76 HeapFree(GetProcessHeap(), 0, This);
78 return RefCount;
81 /* IDirectPlay8ThreadPool interface follows */
82 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Initialize(IDirectPlay8ThreadPool *iface,
83 void * const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags)
85 IDirectPlay8ThreadPoolImpl *This = impl_from_IDirectPlay8ThreadPool(iface);
87 TRACE("(%p)->(%p,%p,%x)\n", This, pvUserContext, pfn, dwFlags);
89 if(!pfn)
90 return DPNERR_INVALIDPARAM;
92 if(threadpool_msghandler)
93 return DPNERR_ALREADYINITIALIZED;
95 threadpool_msghandler = pfn;
96 threadpool_flags = dwFlags;
97 threadpool_usercontext = pvUserContext;
99 return DPN_OK;
102 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Close(IDirectPlay8ThreadPool *iface,
103 const DWORD dwFlags)
105 IDirectPlay8ThreadPoolImpl *This = impl_from_IDirectPlay8ThreadPool(iface);
107 FIXME("(%p)->(%x)\n", This, dwFlags);
109 if(!threadpool_msghandler)
110 return DPNERR_UNINITIALIZED;
112 threadpool_msghandler = NULL;
114 return DPN_OK;
117 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_GetThreadCount(IDirectPlay8ThreadPool *iface,
118 const DWORD dwProcessorNum, DWORD * const pdwNumThreads, const DWORD dwFlags)
120 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dwProcessorNum, pdwNumThreads, dwFlags);
121 *pdwNumThreads = 0;
122 return DPN_OK;
125 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_SetThreadCount(IDirectPlay8ThreadPool *iface,
126 const DWORD dwProcessorNum, const DWORD dwNumThreads, const DWORD dwFlags)
128 FIXME("(%p)->(%x,%x,%x): stub\n", iface, dwProcessorNum, dwNumThreads, dwFlags);
129 return DPN_OK;
132 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_DoWork(IDirectPlay8ThreadPool *iface,
133 const DWORD dwAllowedTimeSlice, const DWORD dwFlags)
135 static BOOL Run = FALSE;
137 if(!Run)
138 FIXME("(%p)->(%x,%x): stub\n", iface, dwAllowedTimeSlice, dwFlags);
140 Run = TRUE;
142 return DPN_OK;
145 static const IDirectPlay8ThreadPoolVtbl DirectPlay8ThreadPool_Vtbl =
147 IDirectPlay8ThreadPoolImpl_QueryInterface,
148 IDirectPlay8ThreadPoolImpl_AddRef,
149 IDirectPlay8ThreadPoolImpl_Release,
150 IDirectPlay8ThreadPoolImpl_Initialize,
151 IDirectPlay8ThreadPoolImpl_Close,
152 IDirectPlay8ThreadPoolImpl_GetThreadCount,
153 IDirectPlay8ThreadPoolImpl_SetThreadCount,
154 IDirectPlay8ThreadPoolImpl_DoWork
157 HRESULT DPNET_CreateDirectPlay8ThreadPool(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj)
159 IDirectPlay8ThreadPoolImpl* Client;
161 Client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8ThreadPoolImpl));
163 if(Client == NULL)
165 *ppobj = NULL;
166 WARN("Not enough memory\n");
167 return E_OUTOFMEMORY;
170 Client->IDirectPlay8ThreadPool_iface.lpVtbl = &DirectPlay8ThreadPool_Vtbl;
171 Client->ref = 0;
173 return IDirectPlay8ThreadPoolImpl_QueryInterface(&Client->IDirectPlay8ThreadPool_iface, riid,
174 ppobj);