[Lazarus] making multithreading more user friendly

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Apr 28 10:21:36 CEST 2012


On Sat, 28 Apr 2012 01:24:03 +0200
Giuliano Colla <giuliano.colla at fastwebnet.it> wrote:

>[...]
> I boldly start a new Application, begin to populate my window with 
> required gadgets, write the thread code, push F9, and my Application 
> crashes. 

Here I get an exception:
 Semaphore init failed (possibly too many concurrent threads)

Maybe this error message should be extended under unix with '... or you
forgot to use the cthreads unit'


> Then I revise my code, looking for all obvious errors, and 
> after a painful search, I discover that I had either forgot to add 
> -dUseCThreads to program options, or , even worse, that I had simply 
> misspelled it.

The -dUseCThreads is for multithreaded packages.

A program can simply remove the {$IFDEF UseCThreads} in the lpr:

  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}

 
>  From the posts I see from time to time in this list, it appears that 
> I'm not the only one to suffer this sort of problem.
> 
> Now I know that it's been debated if multithreading should be enabled by 
> default in Unix environment, and the conclusion has been that it should 
> not. I can't say that I found the arguments against multithreading very 
> convincing, but I don't want to reopen a closed discussion.
> 
> What I ask is: would it be so hard to provide the choice in the "New" 
> dialog? Something like Single Thread Application and Multi Thread 
> Application? The choice could be either hidden or flash an error for the 
> platforms where multithreading is not supported, would be a no-op for 
> Windows, but would make life easier to the rest of us.
> I could provide a patch if pointed to the right area of code to deal 
> with. IDE things remain a big mystery to me.

AFAIK the real pain is to find the cause of the strange/misleading
error messages. The remedy itself is pretty simple (a flag or a tiny
code change).

A new project type is only added if it changes several things not
one flag or one tiny change.

A project has many flags and programmers have different opinions
what flags should be asked on creation.
Maybe some common options can be shown in the "New dialog".


Mattias




More information about the Lazarus mailing list