dplayx: Adjust GetCaps behaviour to documentation
[wine/gsoc_dplay.git] / dlls / dpnet / threadpool.c
blobf94a3fa194e314a251340ec0216f3964f4a3b23d
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
23 #include "config.h"
25 #include <stdarg.h>
27 #define COBJMACROS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "objbase.h"
33 #include "wine/debug.h"
35 #include "dplay8.h"
36 #include "dpnet_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
40 /* IUnknown interface follows */
42 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_QueryInterface(PDIRECTPLAY8THREADPOOL iface, REFIID riid, LPVOID *ppobj)
44 IDirectPlay8ThreadPoolImpl *This = (IDirectPlay8ThreadPoolImpl*)iface;
46 if(IsEqualGUID(riid, &IID_IUnknown) ||
47 IsEqualGUID(riid, &IID_IDirectPlay8ThreadPool))
49 IUnknown_AddRef(iface);
50 *ppobj = This;
51 return DPN_OK;
54 WARN("(%p)->(%s,%p): not found\n", This, debugstr_guid(riid), ppobj);
55 return E_NOINTERFACE;
58 static ULONG WINAPI IDirectPlay8ThreadPoolImpl_AddRef(PDIRECTPLAY8THREADPOOL iface)
60 IDirectPlay8ThreadPoolImpl* This = (IDirectPlay8ThreadPoolImpl*)iface;
61 ULONG RefCount = InterlockedIncrement(&This->ref);
63 return RefCount;
66 static ULONG WINAPI IDirectPlay8ThreadPoolImpl_Release(PDIRECTPLAY8THREADPOOL iface)
68 IDirectPlay8ThreadPoolImpl* This = (IDirectPlay8ThreadPoolImpl*)iface;
69 ULONG RefCount = InterlockedDecrement(&This->ref);
71 if(!RefCount)
72 HeapFree(GetProcessHeap(), 0, This);
74 return RefCount;
77 /* IDirectPlay8ThreadPool interface follows */
78 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Initialize(PDIRECTPLAY8THREADPOOL iface, PVOID CONST pvUserContext, CONST PFNDPNMESSAGEHANDLER pfn, CONST DWORD dwFlags)
80 FIXME("(%p)->(%p,%p,%x): stub\n", iface, pvUserContext, pfn, dwFlags);
81 return DPN_OK;
84 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Close(PDIRECTPLAY8THREADPOOL iface, CONST DWORD dwFlags)
86 return DPN_OK;
89 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_GetThreadCount(PDIRECTPLAY8THREADPOOL iface, CONST DWORD dwProcessorNum, DWORD* CONST pdwNumThreads, CONST DWORD dwFlags)
91 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dwProcessorNum, pdwNumThreads, dwFlags);
92 *pdwNumThreads = 0;
93 return DPN_OK;
96 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_SetThreadCount(PDIRECTPLAY8THREADPOOL iface, CONST DWORD dwProcessorNum, CONST DWORD dwNumThreads, CONST DWORD dwFlags)
98 FIXME("(%p)->(%x,%x,%x): stub\n", iface, dwProcessorNum, dwNumThreads, dwFlags);
99 return DPN_OK;
102 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_DoWork(PDIRECTPLAY8THREADPOOL iface, CONST DWORD dwAllowedTimeSlice, CONST DWORD dwFlags)
104 static BOOL Run = FALSE;
106 if(!Run)
107 FIXME("(%p)->(%x,%x): stub\n", iface, dwAllowedTimeSlice, dwFlags);
109 Run = TRUE;
111 return DPN_OK;
114 static const IDirectPlay8ThreadPoolVtbl DirectPlay8ThreadPool_Vtbl =
116 IDirectPlay8ThreadPoolImpl_QueryInterface,
117 IDirectPlay8ThreadPoolImpl_AddRef,
118 IDirectPlay8ThreadPoolImpl_Release,
119 IDirectPlay8ThreadPoolImpl_Initialize,
120 IDirectPlay8ThreadPoolImpl_Close,
121 IDirectPlay8ThreadPoolImpl_GetThreadCount,
122 IDirectPlay8ThreadPoolImpl_SetThreadCount,
123 IDirectPlay8ThreadPoolImpl_DoWork
126 HRESULT DPNET_CreateDirectPlay8ThreadPool(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj)
128 IDirectPlay8ThreadPoolImpl* Client;
130 Client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8ThreadPoolImpl));
132 if(Client == NULL)
134 *ppobj = NULL;
135 WARN("Not enough memory\n");
136 return E_OUTOFMEMORY;
139 Client->lpVtbl = &DirectPlay8ThreadPool_Vtbl;
140 Client->ref = 0;
142 return IDirectPlay8ThreadPoolImpl_QueryInterface((PDIRECTPLAY8THREADPOOL)Client, riid, ppobj);