On Fri, 2007-08-24 at 22:36 +0000, Mark Carter wrote:
> Not to mention the fact that threads scare me bigtime. From what I've
> heard, I'm right to be scared.

Threads are like cars. Incredibly handy, even life-saving if used right,
but potentially devastating if not respected.

FICL has excellent thread support, just as long as you plan the threads
carefully to avoid train-wrecks, such as multiple threads hitting the
same stack at the same time. I've done a fair bit of multi-thread
programming in FICL, and it's worked out fine.
> 
> A separate window is a logical idea, with an "eval on enter" handler.

>  Don't forget, though, that you can't guarantee how long a word takes
> to execute. It could load other files, and conceivably do just about
> anything. Imagine having a word like "render-project", for example.

You could define a convention, and document it to the user and make it
their responsibility. For instance, tell them that their words should
return quickly, and if they can't, then to spawn a thread.

To spawn a FICL thread, you need to:
  1. create a new FiclVM for that thread's exclusive use
  2. transfer any required arguments off the main thread's stack
     and onto the stack of the thread's FiclVM
  3. spawn a pthread, passing it a pointer to the new FiclVM and
     a pointer to whatever needs to be executed, whether an arbitrary
     text command line or a pointer to a primitive function
  4. Have some synchronisation, such as a global bool flag, so
     the main thread can test if the child thread is done

Cheers
David

> ----- Original Message ----
> From: David McNab <[EMAIL PROTECTED]>
> To: [email protected]
> Sent: Friday, 24 August, 2007 10:54:35 PM
> Subject: Re: [CinCVS] Some Ficl documentation for you
> 
> On Sat, 2007-08-25 at 09:42 +1200, David McNab wrote:
> > In a multi-thread environment such as Cin, you have to change from
> the
> > 'read/eval loop' to an 'eval-on-Enter handler'.
> 
> Oh, I forgot to mention - FICL supports this perfectly. It has a
> function to evaluate an arbitrary text command.
> 
> Cheers
> David
> 
> 
> 
> _______________________________________________
> Cinelerra mailing list
> [email protected]
> https://init.linpro.no/mailman/skolelinux.no/listinfo/cinelerra
> 
> 
> 
> 
> 
> ______________________________________________________________________
> Yahoo! Answers - Get better answers from someone who knows. Try it
> now.


_______________________________________________
Cinelerra mailing list
[email protected]
https://init.linpro.no/mailman/skolelinux.no/listinfo/cinelerra

Reply via email to