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
33 #include "wine/debug.h"
35 #include "dpnet_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dpnet
);
39 static inline IDirectPlay8ThreadPoolImpl
*impl_from_IDirectPlay8ThreadPool(IDirectPlay8ThreadPool
*iface
)
41 return CONTAINING_RECORD(iface
, IDirectPlay8ThreadPoolImpl
, IDirectPlay8ThreadPool_iface
);
44 /* IUnknown interface follows */
45 static HRESULT WINAPI
IDirectPlay8ThreadPoolImpl_QueryInterface(IDirectPlay8ThreadPool
*iface
,
46 REFIID riid
, void **ppobj
)
48 IDirectPlay8ThreadPoolImpl
*This
= impl_from_IDirectPlay8ThreadPool(iface
);
50 if(IsEqualGUID(riid
, &IID_IUnknown
) ||
51 IsEqualGUID(riid
, &IID_IDirectPlay8ThreadPool
))
53 IUnknown_AddRef(iface
);
58 WARN("(%p)->(%s,%p): not found\n", This
, debugstr_guid(riid
), ppobj
);
62 static ULONG WINAPI
IDirectPlay8ThreadPoolImpl_AddRef(IDirectPlay8ThreadPool
*iface
)
64 IDirectPlay8ThreadPoolImpl
* This
= impl_from_IDirectPlay8ThreadPool(iface
);
65 ULONG RefCount
= InterlockedIncrement(&This
->ref
);
70 static ULONG WINAPI
IDirectPlay8ThreadPoolImpl_Release(IDirectPlay8ThreadPool
*iface
)
72 IDirectPlay8ThreadPoolImpl
* This
= impl_from_IDirectPlay8ThreadPool(iface
);
73 ULONG RefCount
= InterlockedDecrement(&This
->ref
);
76 HeapFree(GetProcessHeap(), 0, This
);
81 /* IDirectPlay8ThreadPool interface follows */
82 static HRESULT WINAPI
IDirectPlay8ThreadPoolImpl_Initialize(IDirectPlay8ThreadPool
*iface
,
83 void * const pvUserContext
, const PFNDPNMESSAGEHANDLER pfn
, const DWORD dwFlags
)
85 FIXME("(%p)->(%p,%p,%x): stub\n", iface
, pvUserContext
, pfn
, dwFlags
);
89 static HRESULT WINAPI
IDirectPlay8ThreadPoolImpl_Close(IDirectPlay8ThreadPool
*iface
,
95 static HRESULT WINAPI
IDirectPlay8ThreadPoolImpl_GetThreadCount(IDirectPlay8ThreadPool
*iface
,
96 const DWORD dwProcessorNum
, DWORD
* const pdwNumThreads
, const DWORD dwFlags
)
98 FIXME("(%p)->(%x,%p,%x): stub\n", iface
, dwProcessorNum
, pdwNumThreads
, dwFlags
);
103 static HRESULT WINAPI
IDirectPlay8ThreadPoolImpl_SetThreadCount(IDirectPlay8ThreadPool
*iface
,
104 const DWORD dwProcessorNum
, const DWORD dwNumThreads
, const DWORD dwFlags
)
106 FIXME("(%p)->(%x,%x,%x): stub\n", iface
, dwProcessorNum
, dwNumThreads
, dwFlags
);
110 static HRESULT WINAPI
IDirectPlay8ThreadPoolImpl_DoWork(IDirectPlay8ThreadPool
*iface
,
111 const DWORD dwAllowedTimeSlice
, const DWORD dwFlags
)
113 static BOOL Run
= FALSE
;
116 FIXME("(%p)->(%x,%x): stub\n", iface
, dwAllowedTimeSlice
, dwFlags
);
123 static const IDirectPlay8ThreadPoolVtbl DirectPlay8ThreadPool_Vtbl
=
125 IDirectPlay8ThreadPoolImpl_QueryInterface
,
126 IDirectPlay8ThreadPoolImpl_AddRef
,
127 IDirectPlay8ThreadPoolImpl_Release
,
128 IDirectPlay8ThreadPoolImpl_Initialize
,
129 IDirectPlay8ThreadPoolImpl_Close
,
130 IDirectPlay8ThreadPoolImpl_GetThreadCount
,
131 IDirectPlay8ThreadPoolImpl_SetThreadCount
,
132 IDirectPlay8ThreadPoolImpl_DoWork
135 HRESULT
DPNET_CreateDirectPlay8ThreadPool(LPCLASSFACTORY iface
, LPUNKNOWN punkOuter
, REFIID riid
, LPVOID
*ppobj
)
137 IDirectPlay8ThreadPoolImpl
* Client
;
139 Client
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectPlay8ThreadPoolImpl
));
144 WARN("Not enough memory\n");
145 return E_OUTOFMEMORY
;
148 Client
->IDirectPlay8ThreadPool_iface
.lpVtbl
= &DirectPlay8ThreadPool_Vtbl
;
151 return IDirectPlay8ThreadPoolImpl_QueryInterface(&Client
->IDirectPlay8ThreadPool_iface
, riid
,