Re: [sqlite] Thread handling in Windows

2006-01-12 Thread Dennis Jenkins
[EMAIL PROTECTED] wrote: Every Windows DLL can provide a DllMain function. This function gets called whenever a thread gets created or destroyed. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/dllmain.asp Except that not all of us use Sqlite as a DLL. We

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread John Stanton
Imagine how different the IT world would be if Microsoft had hired computer scientists instead of lawyers. We can but dream. [EMAIL PROTECTED] wrote: "Robert Simpson" <[EMAIL PROTECTED]> wrote: Not quite so straightforward in Windows: Seems like nothing ever is. (sigh) My life would

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread Robert Simpson
Rats! It figures that I'd read this right after hitting the send button: (From MSDN) If a DLL declares any nonlocal data or object as __declspec( thread ), it can cause a protection fault if dynamically loaded. After the DLL is loaded with LoadLibrary, it causes system failure whenever the

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread Robert Simpson
- Original Message - From: <[EMAIL PROTECTED]> It makes the code smaller and faster to set a flag when malloc fails, rather than trying to test for the failure all the way back up the stack. The flag used to be a global variable. But that was causing problems for embedded device

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread drh
Teg <[EMAIL PROTECTED]> wrote: > Hello drh, > > Could you perhaps give us the rational for using TLS? How is it that > TLS is needed on cases where you run out of memory? It makes the code smaller and faster to set a flag when malloc fails, rather than trying to test for the failure all the way

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread Teg
Hello drh, Could you perhaps give us the rational for using TLS? How is it that TLS is needed on cases where you run out of memory? By using TLS you're essentially making SQlite thread aware where I'd prefer it to know nothing about thread contexts or whether it's running in a thread or not. How

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread Robert Simpson
- 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

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread Will Leshner
On Jan 11, 2006, at 7:43 AM, [EMAIL PROTECTED] wrote: Seems like nothing ever is. (sigh) My life would be so much simpler if Bill Gates has stayed in school long enough to take just one course in operating systems... LOL! That's about the funniest thing I've ever heard. Do we have

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread Miguel Angel Latorre Díaz
I'm the one who posted ticket 1601. I have a multithreaded sqlite tcp server, and it ran fine with 2.8.x and 3.x versions, but this "feature" is a stopper for me. I think there is no difference using a dll or not, there is no way to free that thread memory allocated, since that function it

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread drh
"Robert Simpson" <[EMAIL PROTECTED]> wrote: > > I haven't looked too closely at the thread local data stuff recently added > to SQLite, however, is there a way to have it default to off, and opt-in at > runtime? No. Thread-local storage is needed to recover from out-of-memory errors. It is

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread Robert Simpson
- Original Message - From: <[EMAIL PROTECTED]> In the unix world using pthreads, when you allocate thread-local storage, you specify a callback function to delete the storage when the thread terminates. This callback is the second argument to pthread_key_create(), See, for example,

RE: [sqlite] Thread handling in Windows

2006-01-11 Thread Fred Williams
Damn! Then he would have ALL the money, not just a few billion! :-) > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Wednesday, January 11, 2006 9:44 AM > To: sqlite-users@sqlite.org > Subject: Re: [sqlite] Thread handling in Windows

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread Robert Simpson
- Original Message - From: <[EMAIL PROTECTED]> "Robert Simpson" <[EMAIL PROTECTED]> wrote: Not quite so straightforward in Windows: Seems like nothing ever is. (sigh) My life would be so much simpler if Bill Gates has stayed in school long enough to take just one course in

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread drh
"Robert Simpson" <[EMAIL PROTECTED]> wrote: > > Not quite so straightforward in Windows: > Seems like nothing ever is. (sigh) My life would be so much simpler if Bill Gates has stayed in school long enough to take just one course in operating systems... -- D. Richard Hipp <[EMAIL PROTECTED]>

RE: [sqlite] Thread handling in Windows

2006-01-11 Thread Brandon, Nicholas
>Question: How do you do the same thing on windows? >How do you get a thread to clean up its thread-local-storage >obtained using TlsAlloc() and TlsSetValue() when the >thread terminates? You may find this example useful: http://www.codeproject.com/threads/tls.asp Regards Nick

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread Robert Simpson
- Original Message - From: <[EMAIL PROTECTED]> In the unix world using pthreads, when you allocate thread-local storage, you specify a callback function to delete the storage when the thread terminates. This callback is the second argument to pthread_key_create(), See, for example,

Re: [sqlite] Thread handling in Windows

2006-01-11 Thread ralf . deininger
Every Windows DLL can provide a DllMain function. This function gets called whenever a thread gets created or destroyed. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/dllmain.asp Some example code: /** \brief */ BOOL WINAPI DllMain( HINSTANCE hinstDLL,