Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Michael Schnell
On 10/09/2011 01:22 AM, Frank Church wrote: Are multiple critical sections allowed in form or data module? I don't understand your concern. A DataModule is a way to organize the makeup and dependance of objects (so strictly a question of data in memory). A CriticalSection is a way to

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Michael Schnell
On 10/09/2011 09:14 AM, Frank Church wrote: Do you mean that TCriticalSection is part of the LCL and shouldn't be run from within a thread, or that code within the thread or the critical section must not run code accessing the LCL? TCriticalSection is obviously done to be used in Thread.

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Michael Schnell
On 10/09/2011 09:55 AM, Mattias Gaertner wrote: All LCL code that deals with Application, ... is not thread safe and should only be accessed by the main thread. Hmmm. Application.QueuAsyncCall() is obviously created to be called by a thread. So it's necessary to read the documentation to be

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Michael Schnell
On 10/09/2011 09:55 AM, Mattias Gaertner wrote: On Sun, 9 Oct 2011 08:14:41 +0100 Frank Churchvfcli...@gmail.com wrote: How is it determined whether a piece of code runs within the LCL or not? if GetCurrentThreadID=MainThreadID then I understand his question as How to find out whether a

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Michael Schnell
On 10/09/2011 10:49 AM, Hans-Peter Diettrich wrote: The LCL is not reentrant. All code accessing the LCL should run in the main thread (see Synchronize...), not in other threads. Not true in this intensity. There are functions in the LCL especially doe not be called by worker Threads, and

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Michael Schnell
On 10/09/2011 02:37 PM, Hans-Peter Diettrich wrote: Mattias Gaertner schrieb: Most LCL code is reentrant. Only within the context of an single thread. In a single threadded application only recursive functions can have reentrancy problems. As nearly all user code is done as an event

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Michael Schnell
On 10/09/2011 03:14 PM, Michael Van Canneyt wrote: It's not so on Unix. X-Windows is definitely not thread-safe. Of course in general this is correct. But I understand that it should be possible that an application (using additional threads) creates more than one Main Frame by attaching to a

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Michael Schnell
On 10/10/2011 10:23 AM, Michael Schnell wrote: type: There are functions in the LCL especially done be called by worker Threads,... -Michael -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Michael Schnell
Type: LCL -Michael -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Marco van de Voort
On Sun, Oct 09, 2011 at 03:14:54PM +0200, Michael Van Canneyt wrote: It's not so on Unix. X-Windows is definitely not thread-safe. And neither is OpenGL (and afaik Direct X also) -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread michael . vancanneyt
On Mon, 10 Oct 2011, Michael Schnell wrote: On 10/09/2011 03:14 PM, Michael Van Canneyt wrote: It's not so on Unix. X-Windows is definitely not thread-safe. Of course in general this is correct. But I understand that it should be possible that an application (using additional threads)

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Hans-Peter Diettrich
Michael Schnell schrieb: In fact the help for any LCL and RTL function should say how it can be used regarding threads. Currently it's sufficient to know that the LCL is not threadsafe. It is known that any function that accesses the GUI can only be called by the main thread. That's one

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Michael Schnell
On 10/10/2011 10:34 AM, michael.vancann...@wisa.be wrote: I don't think that the LCL should support this. I did not want to suggest that it should (IMHO it would be nice to have this as a special Application type, but it's (a) not easy to do and (b) quite low priority. I in fact do have a

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Hans-Peter Diettrich
Michael Schnell schrieb: On 10/09/2011 03:14 PM, Michael Van Canneyt wrote: It's not so on Unix. X-Windows is definitely not thread-safe. Of course in general this is correct. But I understand that it should be possible that an application (using additional threads) creates more than one

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-10 Thread Michael Schnell
On 10/10/2011 11:36 AM, Hans-Peter Diettrich wrote: Michael Schnell schrieb: In fact the help for any LCL and RTL function should say how it can be used regarding threads. Currently it's sufficient to know that the LCL is not threadsafe. So you claim that nobody should use

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-09 Thread Mattias Gaertner
On Sun, 9 Oct 2011 00:22:10 +0100 Frank Church vfcli...@gmail.com wrote: Are multiple critical sections allowed in form or data module? e.g. I have different datasets each with its own connection and queries that threads need to lookup data from. Is it acceptable to have additional

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-09 Thread Frank Church
On 9 October 2011 07:30, Mattias Gaertner nc-gaert...@netcologne.de wrote: On Sun, 9 Oct 2011 00:22:10 +0100 Frank Church vfcli...@gmail.com wrote: Are multiple critical sections allowed in form or data module? e.g. I have different datasets each with its own connection and queries that

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-09 Thread Hans-Peter Diettrich
Frank Church schrieb: Is it acceptable to have additional TCriticalSections on the form? Yes. I hope you are aware that all code accessing the LCL must run in the main thread. Mattias Can you explain this? A critical section blocks all code, that wants to enter the

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-09 Thread Mattias Gaertner
On Sun, 9 Oct 2011 08:14:41 +0100 Frank Church vfcli...@gmail.com wrote: On 9 October 2011 07:30, Mattias Gaertner nc-gaert...@netcologne.de wrote: On Sun, 9 Oct 2011 00:22:10 +0100 Frank Church vfcli...@gmail.com wrote: Are multiple critical sections allowed in form or data module?

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-09 Thread Mattias Gaertner
On Sun, 09 Oct 2011 10:49:31 +0200 Hans-Peter Diettrich drdiettri...@aol.com wrote: [...] The LCL is not reentrant. Most LCL code is reentrant. An event can trigger an event. On of the few exceptions is destroying a control. That's why there is Application.ReleaseComponent. [...] Mattias

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-09 Thread Hans-Peter Diettrich
Mattias Gaertner schrieb: On Sun, 09 Oct 2011 10:49:31 +0200 Hans-Peter Diettrich drdiettri...@aol.com wrote: [...] The LCL is not reentrant. Most LCL code is reentrant. Only within the context of an single thread. This was acceptable on traditional single-CPU/core machines, but

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-09 Thread Michael Van Canneyt
On Sun, 9 Oct 2011, Hans-Peter Diettrich wrote: Mattias Gaertner schrieb: On Sun, 09 Oct 2011 10:49:31 +0200 Hans-Peter Diettrich drdiettri...@aol.com wrote: [...] The LCL is not reentrant. Most LCL code is reentrant. Only within the context of an single thread. This was acceptable

Re: [Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-09 Thread Hans-Peter Diettrich
Michael Van Canneyt schrieb: On Sun, 9 Oct 2011, Hans-Peter Diettrich wrote: Mattias Gaertner schrieb: On Sun, 09 Oct 2011 10:49:31 +0200 Hans-Peter Diettrich drdiettri...@aol.com wrote: [...] The LCL is not reentrant. Most LCL code is reentrant. Only within the context of an single

[Lazarus] Are multiple critical sections allowed in form or data module?

2011-10-08 Thread Frank Church
Are multiple critical sections allowed in form or data module? e.g. I have different datasets each with its own connection and queries that threads need to lookup data from. Is it acceptable to have additional TCriticalSections on the form? -- Frank Church ===