MTA with thread pool API
- From: "Sarge" <not@xxxxxxxx>
- Date: Tue, 06 Jun 2006 16:12:59 GMT
Hi group,
I have a C/C++ multi-threaded socket server app that uses OLE DB for it's
SQL activity. The app uses a completion port for socket I/O, but doesn't
properly implement connection pooling with OLE DB. Each thread of the
process holds on to it's own IDBInitialize, which I know is wrong.
So I'm rewriting this app to maintain one IDataInitialize object, and create
the IDBInitialize objects on the fly, using the same connection string.
Hopefully, this won't add too much overhead, but it's what Microsoft says to
do for proper connection pooling.
Anyway, my question is related to CoInitializeEx(MTA) / CoUninitialize() in
regards to the thread pool API. I really like using this API -
QueueUserWorkItem(), BindIoCompletionCallback(),
RegisterWaitForSingleObject(), etc.
The problem is that Windows manages these threads, so I don't have the
opportunity to call CoInitializeEx / CoUninitialize. Using Thread Local
Storage, I can flag whether or not the thread has called CoInitializeEx, but
I still have no opportunity to call CoUninitialize.
Microsoft is very clear that you must call these functions once per thread
that uses COM. I thought about moving all the code into a DLL, and using
THREAD_ATTACH and THREAD_DETACH, but the SDK also says not to call the
CoInit functions from DLLMain().
Does this mean that I'm stuck with my own completion ports, or is there some
way that I can use the thread pool API?
I know this all sounds like a bunch of mumbo jumbo, so please ask and I'll
clarify any points above.
Thanks for your time.
--Sarge
.
- Follow-Ups:
- Re: MTA with thread pool API
- From: Erland Sommarskog
- Re: MTA with thread pool API
- Prev by Date: Cannot determine a specific error code using OleDbConnection with Client Access Express
- Next by Date: Re: OLE DB 2.8 & SQL 2005
- Previous by thread: Cannot determine a specific error code using OleDbConnection with Client Access Express
- Next by thread: Re: MTA with thread pool API
- Index(es):
Relevant Pages
|