Java->Scheme doubts, please help...

Antonio <[email protected]> Wed, 22 Nov 2006 13:02:30 +0100
Newsgroups gmane.comp.java.sisc.user
Message-ID <[email protected]>
Hi all,

I am invoking Scheme from Java (external call). And, after reading the
documentation, I still have some doubts on how to do it. I would
appreciate any clarifications.

What I am trying to do is to create a thread that is responsible for
evaluating Scheme code (a "Scheme Evaluator Thread"). The thread will
always be running, waiting for Scheme code to be executed (using a
blocking queue) and other threads will send it requests for execution
asynchronously.

Thanks in advance,
Antonio

1.- AppContext thread safe?

I am creating an AppContext object. The documentation says that
AppContexts "are unique to a single usage of SISC".

I am confused by that sentence. Shall I create an AppContext from every
thread using SISC? Or may I share it from different threads? Are
"AppContexts" thread safe? (i.e.: can a single AppContext work with
different interpreters?)

Suggestion: rephrase "single usage of SISC".


2.- Using interpreters.

Once I create my AppContext (and once the heap is added to it) I must
create an interpreter for each thread I use. Now, how do I create an
interpreter from the AppContext?

2.1.- Option I:

  It seems I can use
          Interpreter myInterpreter = Context.enter( myAppContext );
  - Now, this  is not documented! Is this thread safe/correct?
  - Will this create a dynamic environment for the current thread
automatically?
  - If I keep this "myInterpreter" in my thread I assume I can use it to
evaluate different Scheme code, right?

2.2.- Option II:

  The documentation suggests the following "managed" call:
         Object result = Context.execute( myAppContext, mySchemeCaller );
  I assume this creates an Interpreter, invokes the
"mySchemeCaller.execute(Interpreter)" and then automatically exists the
interpreter, right?
  I won't be able to use this mechanism in my "Scheme Evaluator Thread",
because the intepreter will be created and destroyed automatically (right?).

2.3.- Option III:
  The third option consists of getting an Intepreter using a
DynamicEnvironment, like this:
       Intepreter myInterpreter = Context.enter( myAppContext,
myDynamicEnvironment );

  - Is option (I) above equivalent to Context.enter( myAppContext, null ) ?
  - May I keep "myInterpreter" in my "Scheme evaluator thread"?


Thanks in advance,
Antonio





-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV