2008-07-22 18:50:14 +02:00
|
|
|
/*
|
|
|
|
* DirectPlay8 ThreadPool
|
|
|
|
*
|
|
|
|
* Copyright 2004 Raphael Junqueira
|
2008-10-18 19:19:55 +02:00
|
|
|
* Copyright 2008 Alexander N. Sørnes <alex@thehandofagony.com>
|
2008-07-22 18:50:14 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "dpnet_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
|
|
|
|
|
2017-03-23 02:57:05 +01:00
|
|
|
static PFNDPNMESSAGEHANDLER threadpool_msghandler = NULL;
|
|
|
|
static DWORD threadpool_flags = 0;
|
|
|
|
static void *threadpool_usercontext = NULL;
|
|
|
|
|
2011-08-05 13:12:43 +02:00
|
|
|
static inline IDirectPlay8ThreadPoolImpl *impl_from_IDirectPlay8ThreadPool(IDirectPlay8ThreadPool *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectPlay8ThreadPoolImpl, IDirectPlay8ThreadPool_iface);
|
|
|
|
}
|
2008-07-22 18:50:14 +02:00
|
|
|
|
2011-08-05 13:12:43 +02:00
|
|
|
/* IUnknown interface follows */
|
|
|
|
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_QueryInterface(IDirectPlay8ThreadPool *iface,
|
2021-08-29 14:00:18 +02:00
|
|
|
REFIID riid, void **ret_iface)
|
2008-07-22 18:50:14 +02:00
|
|
|
{
|
2021-08-29 14:00:18 +02:00
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectPlay8ThreadPool))
|
2008-07-22 18:50:14 +02:00
|
|
|
{
|
2021-08-29 14:00:18 +02:00
|
|
|
IDirectPlay8ThreadPool_AddRef(iface);
|
|
|
|
*ret_iface = iface;
|
|
|
|
return S_OK;
|
2008-07-22 18:50:14 +02:00
|
|
|
}
|
|
|
|
|
2021-08-29 14:00:18 +02:00
|
|
|
WARN("(%p)->(%s,%p): not found\n", iface, debugstr_guid(riid), ret_iface);
|
2008-07-22 18:50:14 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2011-08-05 13:12:43 +02:00
|
|
|
static ULONG WINAPI IDirectPlay8ThreadPoolImpl_AddRef(IDirectPlay8ThreadPool *iface)
|
2008-07-22 18:50:14 +02:00
|
|
|
{
|
2011-08-05 13:12:43 +02:00
|
|
|
IDirectPlay8ThreadPoolImpl* This = impl_from_IDirectPlay8ThreadPool(iface);
|
2008-07-22 18:50:14 +02:00
|
|
|
ULONG RefCount = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
return RefCount;
|
|
|
|
}
|
|
|
|
|
2011-08-05 13:12:43 +02:00
|
|
|
static ULONG WINAPI IDirectPlay8ThreadPoolImpl_Release(IDirectPlay8ThreadPool *iface)
|
2008-07-22 18:50:14 +02:00
|
|
|
{
|
2011-08-05 13:12:43 +02:00
|
|
|
IDirectPlay8ThreadPoolImpl* This = impl_from_IDirectPlay8ThreadPool(iface);
|
2008-07-22 18:50:14 +02:00
|
|
|
ULONG RefCount = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
if(!RefCount)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
|
|
|
|
return RefCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IDirectPlay8ThreadPool interface follows */
|
2011-08-05 13:12:43 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Initialize(IDirectPlay8ThreadPool *iface,
|
|
|
|
void * const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags)
|
2008-07-22 18:50:14 +02:00
|
|
|
{
|
2017-02-15 05:36:26 +01:00
|
|
|
IDirectPlay8ThreadPoolImpl *This = impl_from_IDirectPlay8ThreadPool(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p,%p,%x)\n", This, pvUserContext, pfn, dwFlags);
|
|
|
|
|
|
|
|
if(!pfn)
|
|
|
|
return DPNERR_INVALIDPARAM;
|
|
|
|
|
2017-03-23 02:57:05 +01:00
|
|
|
if(threadpool_msghandler)
|
2017-02-15 05:36:26 +01:00
|
|
|
return DPNERR_ALREADYINITIALIZED;
|
|
|
|
|
2017-03-23 02:57:05 +01:00
|
|
|
threadpool_msghandler = pfn;
|
|
|
|
threadpool_flags = dwFlags;
|
|
|
|
threadpool_usercontext = pvUserContext;
|
2017-02-15 05:36:26 +01:00
|
|
|
|
2008-07-22 18:50:14 +02:00
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-05 13:12:43 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Close(IDirectPlay8ThreadPool *iface,
|
|
|
|
const DWORD dwFlags)
|
2008-07-22 18:50:14 +02:00
|
|
|
{
|
2017-02-15 05:36:26 +01:00
|
|
|
IDirectPlay8ThreadPoolImpl *This = impl_from_IDirectPlay8ThreadPool(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%x)\n", This, dwFlags);
|
|
|
|
|
2017-03-23 02:57:05 +01:00
|
|
|
if(!threadpool_msghandler)
|
|
|
|
return DPNERR_UNINITIALIZED;
|
|
|
|
|
|
|
|
threadpool_msghandler = NULL;
|
2017-02-15 05:36:26 +01:00
|
|
|
|
2008-07-22 18:50:14 +02:00
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-05 13:12:43 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_GetThreadCount(IDirectPlay8ThreadPool *iface,
|
|
|
|
const DWORD dwProcessorNum, DWORD * const pdwNumThreads, const DWORD dwFlags)
|
2008-07-22 18:50:14 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p)->(%x,%p,%x): stub\n", iface, dwProcessorNum, pdwNumThreads, dwFlags);
|
|
|
|
*pdwNumThreads = 0;
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-05 13:12:43 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_SetThreadCount(IDirectPlay8ThreadPool *iface,
|
|
|
|
const DWORD dwProcessorNum, const DWORD dwNumThreads, const DWORD dwFlags)
|
2008-07-22 18:50:14 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p)->(%x,%x,%x): stub\n", iface, dwProcessorNum, dwNumThreads, dwFlags);
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-05 13:12:43 +02:00
|
|
|
static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_DoWork(IDirectPlay8ThreadPool *iface,
|
|
|
|
const DWORD dwAllowedTimeSlice, const DWORD dwFlags)
|
2008-07-22 18:50:14 +02:00
|
|
|
{
|
|
|
|
static BOOL Run = FALSE;
|
|
|
|
|
|
|
|
if(!Run)
|
|
|
|
FIXME("(%p)->(%x,%x): stub\n", iface, dwAllowedTimeSlice, dwFlags);
|
|
|
|
|
|
|
|
Run = TRUE;
|
|
|
|
|
|
|
|
return DPN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDirectPlay8ThreadPoolVtbl DirectPlay8ThreadPool_Vtbl =
|
|
|
|
{
|
|
|
|
IDirectPlay8ThreadPoolImpl_QueryInterface,
|
|
|
|
IDirectPlay8ThreadPoolImpl_AddRef,
|
|
|
|
IDirectPlay8ThreadPoolImpl_Release,
|
|
|
|
IDirectPlay8ThreadPoolImpl_Initialize,
|
|
|
|
IDirectPlay8ThreadPoolImpl_Close,
|
|
|
|
IDirectPlay8ThreadPoolImpl_GetThreadCount,
|
|
|
|
IDirectPlay8ThreadPoolImpl_SetThreadCount,
|
|
|
|
IDirectPlay8ThreadPoolImpl_DoWork
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT DPNET_CreateDirectPlay8ThreadPool(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
IDirectPlay8ThreadPoolImpl* Client;
|
|
|
|
|
|
|
|
Client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8ThreadPoolImpl));
|
|
|
|
|
|
|
|
if(Client == NULL)
|
|
|
|
{
|
|
|
|
*ppobj = NULL;
|
|
|
|
WARN("Not enough memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2011-08-05 13:12:43 +02:00
|
|
|
Client->IDirectPlay8ThreadPool_iface.lpVtbl = &DirectPlay8ThreadPool_Vtbl;
|
2008-07-22 18:50:14 +02:00
|
|
|
Client->ref = 0;
|
|
|
|
|
2011-08-05 13:12:43 +02:00
|
|
|
return IDirectPlay8ThreadPoolImpl_QueryInterface(&Client->IDirectPlay8ThreadPool_iface, riid,
|
|
|
|
ppobj);
|
2008-07-22 18:50:14 +02:00
|
|
|
}
|