Subject Re: Hanging by a Thread
Author inoffensive_2006
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@...> wrote:
>
> At 10:37 AM 30/09/2007, you wrote:
>
> > What do you mean "it can't use stuff that was retrieved
> >by another thread."?
>
> The context for all of your transactions, statements, etc., is the
> connection. Each thread has to have its own connection context.
>
> > That's my stuff, isn't it?
>
> Well....what's "my" here? You have a main thread (which can make its
> own connections) and you may have one or more threads, each of which
> makes its own connections. Each connection constitutes one isolated
> microcosm that can't access the others' microcosms. Within one
> thread, you do have the capability of having a transaction that can
> place connections to multiple DIFFERENT databases within the same
> isolation context but that's not pertinent to this particular approach.
>
> >After one thread fetches data from the select, can't the other
> >thread use it?
>
> No.

Thanks again Helen.

I think I'm not being clear. Or I'm confused. "it" means
the data from the select, not the connection. The other thread
can use the data can't it? After what you and Adam have told
me, I wouldn't try to have threads of one process share a
connection.

My approach now is.

Main thread of parent process:

Draw some dialogs

Launch data extraction thread

Wait for message from data extraction thread that info
needed for login to application is available in regular
memory

Run logins using user records retrieved by thread

Create new processes for any task the user chooses to
perform. These processes will traverse a binary tree
in shared memory. They will use the contact's primary
key, found in a node of the tree, to extract columns
from the contact table.

The main thread never connects to the database. If it
ever needs to in the future, it will be after data
extraction thread is finished.

Data extraction thread (For parent process):

Connect to Firebird

Extract information needed for user login to application
in regular memory

Inform main thread login information is present

Load small number of columns from each row of contact
table into binary tree in shared memory

Inform any processes waiting for the contact information
of the progress of the load.

Disconnect from the database.

end

Only one connection will be made by a process.

Does this sound like it will work?

Sorry about being so dense. But that's just the way I am.

Thanks
Larry