On Nov 8, 2009, at 19:41, Andy Stewart wrote:

> Hi Axel,
>
> Now i try to write some multi-process program, so i need use NamedPipe
> to communication with those processes (ParentProcess and  
> ChildProcess).
> And i need use multi-thread to do concurrent in process, example,  
> some thread to
> paint UI, some thread to communication with other process through
> NamedPipe.
>
> But i saw you write below notes on gtk2hs homepage:
>
> ------------------------------> notes start  
> <------------------------------
> A note of caution: Using Gtk2Hs together with the -threaded ghc is
> currently not supported. The reason is that GHC’s garbage collector
> might free Xlib or Win32 objects using an OS thread different to  
> the one
> that is used to execute all other Gtk+ functions. The result will be a
> program that occasionally fails with an Xlib error or a crash on
> Windows. We are working on fixing this.
> ------------------------------> notes end    
> <------------------------------
>
> So it's a big problem in linux? When you said *occasionally* fails.

It affects Linux as well as Windows.

> Is it easy to fix?

It's not clear what the best fix is. The problem is that finalizers  
of objects are called by the GC using a thread that might be  
different from the thread that runs the Gtk+ main loop. Indeed, the  
Gtk+ main loop might be running while the GC finalizes some objects  
that may thereby release Xlib or Win32 resources. This creates calls  
to Xlib or Win32 that are concurrent with respect to whatever the Gtk 
+ main loop does. We need to avoid this and it is not clear what the  
best way is.

> Can you give me some suggestions before i write multi-threads program?

The best way for now is to try to write a program that does not need  
the -threaded flag of ghc, i.e. to write a program that does not use  
blocking C calls. I don't know if that is an option when you need  
named pipes. In any way, I think we can fix the problem before the  
next release.

Cheers,
Axel.

> Thanks,
>
>   -- Andy
>
>
> ---------------------------------------------------------------------- 
> --------
> Let Crystal Reports handle the reporting - Free Crystal Reports  
> 2008 30-Day
> trial. Simplify your report design, integration and deployment -  
> and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Gtk2hs-devel mailing list
> Gtk2hs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gtk2hs-devel mailing list
Gtk2hs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel

Reply via email to