Re: weird XPCE threading issue ?

Jan Wielemaker <[email protected]> Mon, 7 Apr 2014 13:43:57 +0200
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 04/07/2014 11:54 AM, Carlo Capelli wrote:
> Some time ago I answered this question (
> http://stackoverflow.com/questions/12158293/xpce-for-prolog-in-compiled-files/12165153#12165153),
> and wrote this snippet:
>
> :- use_module(library(pce)).
> :- use_module(library(plot/barchart)).
> :- use_module(library(autowin)).
>
> test_barchart :-
>      new(W, picture),
>      send(W, display, new(BC, bar_chart(vertical,0,200))),
>      forall(member(Name/Height/Color,
>                [x/100/red, y/150/green, z/80/blue, v/50/yellow]),
>             (   new(B, bar(Name, Height)),
>                 send(B, colour(Color)),
>                 send(BC, append, B)
>             )),
>      send(W, open).
>
> Now I tried again that code, and I was left to stare at a blinking cursor
> on an empty line...
>
> After some test I found that commenting out, in ~/.plrc
>
> :- set_prolog_flag(xpce_threaded, true).
>
> it worked again. I feel the problem it's over my head...

XPCE isn't very good at threading.  Worse, the problems are quite 
different on Windows and X11, while the Mac has its own problems ...
So, run it in a single thread and communicate with it using
in_pce_thread/1 and in_pce_thread_sync/1 from other threads.

If you use the xpce_threaded flag, it will settle itself on a
thread named `pce`, which is great for development as the development
system remains responsive while your application runs.  If you want to
do *xpce development*, it is probably wiser to keep xpce in the main
thread.  Once you are finished, you can revert to threaded mode and
use ?- in_pce_thread(start_my_app). to launch the application.

Hope this clarifies a bit.  My $0.002: write graphical applications
as web applications.  Looks better, good portability, network
transparency if you need it, etc.

	Cheers --- Jan


>
> Carlo
> -------------- next part --------------
> HTML attachment scrubbed and removed
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>