----- Original Message ----- From: <[EMAIL PROTECTED]>
No.  Thread-local storage is needed to recover from out-of-memory
errors.  It is not optional.

There is one way to do this, but it might be ugly.

The way I see it, the problem lies in the fact that you are never notified when a thread terminates. The only way to detect if a thread has terminated is to call GetExitCodeThread() and if the status is not STILL_ACTIVE, then the thread is dead. In order to call that function, you need a thread handle. Which means that whenever you allocate new tls data for a given thread, you must call DuplicateHandle(GetCurrentThread()) and store the copy of the thread handle in a linked list.

So that leaves you with periodically scanning through the list looking for threads that have disappeared, and once gone, you raise the callback routine and destroy their tls data and close the thread handle.

Perhaps it could be done during sqlite_reset, or sqlite_finalize or sqlite_prepare ... but its not quite as elegant as the *nix way.

Robert


Reply via email to