Do yourself a favor. Create a CPool
class that has a Get( ) and a Put( ) with a collection class that you would like
to use as the member. Whenever you call Get( ) if you have a DB connection,
remove it from the collection and hand it back in the return. If you don't have
a DB connection, create one and return that. The Put( ) just sticks the DB
connection back into the collection. Wrap the collection access with a critical
section.
This way you will create only the
necessary number of DB connections and not one more (what if you only need 10
and not 30?) *and* you are guaranteed to have a DB collection whenever you need
one (what if you need 31?). Also the critical section is the fastest
single-process lock mechanism.
If you want to limit the DB
connections to one set number (like 30) you'll need to add a counter that is
incremented every time you create a new DB connection. Once you reach 30, you
don't create any more - instead you block on an event that is set as soon as a
handle is returned to the collection, and then you step into the critical
section and get that handle.
What makes you think ISAPI doesn't
use IOCP?
|
_______________________________________________ msvc mailing list msvc@beginthread.com See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.