| "Michael Gogins" writes:
> The console version of csound 5, and the CsoundVST version, will
> both run the FLTK orchestras.
So far, the only viable, thread-safe method I can think of to support
both CsoundVST and console Csound involves changing the semantics of
the Csound API. I suggest that FLTK GUI clients of the API be
required to call void csoundSetIsGraphable(void *, int) with a
negative number as its second argument before anything is performed.
When informed of being a used by an FLTK GUI, the widgets would be
used in slave mode. In slave mode, all FLTK access would be
encapsulated by an Fl::lock/Fl::unlock pair, and the FLrun opcode
would just show its panels. It would not create a thread.
In master mode, each FLTK access performed before FLrun would not be
encapsulated by an Fl::lock/Fl::unlock pair, and the FLrun opcode
would run a thread that immediately calls Fl::lock, and later on,
Fl::run. This thread would be console Csound's main thread.
John
> ----- Original Message -----
> From: "John D. Ramsdell"
> To: "Csound Developers Discussion List"
> Sent: Monday, December 27, 2004 4:17 PM
> Subject: [CSOUND-DEV:5596] RE: FLTK threading rules and Csound4
>
>
> > Victor Lazzarini writes:
> >
> >> Widgets.cpp on csound5 uses Fl::lock etc.
> >
> > This made me optimistic that one need only back port the Csound5
> > version of widgets.cpp to Csound4, but after reviewing the file, I
> > don't think it's that easy. This code puts an Fl::lock/Fl::unlock
> > pair around two occurrences of Fl::wait. That's because there are two
> > threads that perform an Fl::wait!
> >
> > Once again, this is bad news for CsoundVST and flCsound. My reading
> > of the FLTK manual says that only the main thread is permitted to call
> > Fl::wait or Fl::check. And there is another potential problem. FLTK
> > accesses in child threads should be surround by Fl::lock/Fl::unlock
> > pairs, but the main thread should call the Fl::lock once, and hold the
> > lock. The routines in the Csound5 version of widgets.cpp are
> > appropriate for use in child threads, but never as the main thread.
> > My question is, what happens when Csound5 is run in console only mode?
> > What thread is the main thread? It cannot be the one that runs
> > fltkRun, as it drops its lock after each call to Fl::wait.
> >
> >> I don't think the FLTK lib check is needed, because csound5
> >> will not build properly if FL::lock() is not there.
> >
> > I don't understand why one cannot design Csound5 so that it can be
> > built when FLTK is available only as a single threaded library.
> >
> > Once widgets.cpp is multi-threading enabled in Csound4, the Csound4
> > autoconf script will be changed so it only builds libcsound with FLTK
> > routines when the FLTK library supports multi-threading. It will
> > build flCsound whenever FLTK is present. The single threaded version
> > of flCsound works just fine in this case.
> >
> > John
> >
> > |