Add AppDefaults app selection to control panel
[wine/gsoc-2012-control.git] / dlls / dpnet / threadpool.c
blob274789d28b699e0d391e436e963ac0202fee33ff
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 static inline IDirectPlay8ThreadPoolImpl *impl_from_IDirectPlay8ThreadPool(IDirectPlay8ThreadPool *iface)
42 return CONTAINING_RECORD(iface, IDirectPlay8ThreadPoolImpl, IDirectPlay8ThreadPool_iface);
45 /* IUnknown interface follows */
46 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_QueryInterface(IDirectPlay8ThreadPool *iface,
47 REFIID riid, void **ppobj)
49 IDirectPlay8ThreadPoolImpl *This = impl_from_IDirectPlay8ThreadPool(iface);
51 if(IsEqualGUID(riid, &IID_IUnknown) ||
52 IsEqualGUID(riid, &IID_IDirectPlay8ThreadPool))
54 IUnknown_AddRef(iface);
55 *ppobj = This;
56 return DPN_OK;
59 WARN("(%p)->(%s,%p): not found\n", This, debugstr_guid(riid), ppobj);
60 return E_NOINTERFACE;
63 static ULONG WINAPI IDirectPlay8ThreadPoolImpl_AddRef(IDirectPlay8ThreadPool *iface)
65 IDirectPlay8ThreadPoolImpl* This = impl_from_IDirectPlay8ThreadPool(iface);
66 ULONG RefCount = InterlockedIncrement(&This->ref);
68 return RefCount;
71 static ULONG WINAPI IDirectPlay8ThreadPoolImpl_Release(IDirectPlay8ThreadPool *iface)
73 IDirectPlay8ThreadPoolImpl* This = impl_from_IDirectPlay8ThreadPool(iface);
74 ULONG RefCount = InterlockedDecrement(&This->ref);
76 if(!RefCount)
77 HeapFree(GetProcessHeap(), 0, This);
79 return RefCount;
82 /* IDirectPlay8ThreadPool interface follows */
83 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Initialize(IDirectPlay8ThreadPool *iface,
84 void * const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags)
86 FIXME("(%p)->(%p,%p,%x): stub\n", iface, pvUserContext, pfn, dwFlags);
87 return DPN_OK;
90 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Close(IDirectPlay8ThreadPool *iface,
91 const DWORD dwFlags)
93 return DPN_OK;
96 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_GetThreadCount(IDirectPlay8ThreadPool *iface,
97 const DWORD dwProcessorNum, DWORD * const pdwNumThreads, const DWORD dwFlags)
99 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dwProcessorNum, pdwNumThreads, dwFlags);
100 *pdwNumThreads = 0;
101 return DPN_OK;
104 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_SetThreadCount(IDirectPlay8ThreadPool *iface,
105 const DWORD dwProcessorNum, const DWORD dwNumThreads, const DWORD dwFlags)
107 FIXME("(%p)->(%x,%x,%x): stub\n", iface, dwProcessorNum, dwNumThreads, dwFlags);
108 return DPN_OK;
111 static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_DoWork(IDirectPlay8ThreadPool *iface,
112 const DWORD dwAllowedTimeSlice, const DWORD dwFlags)
114 static BOOL Run = FALSE;
116 if(!Run)
117 FIXME("(%p)->(%x,%x): stub\n", iface, dwAllowedTimeSlice, dwFlags);
119 Run = TRUE;
121 return DPN_OK;
124 static const IDirectPlay8ThreadPoolVtbl DirectPlay8ThreadPool_Vtbl =
126 IDirectPlay8ThreadPoolImpl_QueryInterface,
127 IDirectPlay8ThreadPoolImpl_AddRef,
128 IDirectPlay8ThreadPoolImpl_Release,
129 IDirectPlay8ThreadPoolImpl_Initialize,
130 IDirectPlay8ThreadPoolImpl_Close,
131 IDirectPlay8ThreadPoolImpl_GetThreadCount,
132 IDirectPlay8ThreadPoolImpl_SetThreadCount,
133 IDirectPlay8ThreadPoolImpl_DoWork
136 HRESULT DPNET_CreateDirectPlay8ThreadPool(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj)
138 IDirectPlay8ThreadPoolImpl* Client;
140 Client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8ThreadPoolImpl));
142 if(Client == NULL)
144 *ppobj = NULL;
145 WARN("Not enough memory\n");
146 return E_OUTOFMEMORY;
149 Client->IDirectPlay8ThreadPool_iface.lpVtbl = &DirectPlay8ThreadPool_Vtbl;
150 Client->ref = 0;
152 return IDirectPlay8ThreadPoolImpl_QueryInterface(&Client->IDirectPlay8ThreadPool_iface, riid,
153 ppobj);