On Jan 24, 2008 10:16 PM, Michael Goffioul <[EMAIL PROTECTED]> wrote:
> On 1/24/08, Olivier Lefevre <[EMAIL PROTECTED]> wrote:
> > I'm looking at the source now. If you want the equivalent of
> > the octave_main function from src/octave.cc without the call
> > to main_loop, doesn't the embedded argument to octave_main
> > already let you do that?
>
> Indeed, I overlooked that. It might then be easier than I thought.
> If you're willing to implement it and you succeed, I'll integrate your
> changes in the java package.

If it can help you, here are some hints about how I would
do it:
- don't re-use the Octave.java class; it has been designed to
  work with JHandles in order to execute callbacks synchronously
  with an interactive octave.
- don't re-use the input_event_hook, this is mainly useful when
  you want to synchronize with an interactive octave, which is
  not what you want.
- don't try to initialize the java package (by calling java_init for
  instance); this will be done automatically by the octave engine
  when it needs it; the java package is able to attach itself to
  a running JVM, instead of starting a new one; however there
  are some java properties that would need to be defined by
  the calling java application
- define a new OctaveEngine class
- add a native start method to start the octave engine: calls
  octave_main with embedded set to true
- add native methods to call octave functions, eval strings...
  (there you can re-use the box/unbox functions to perform
  octave/java object conversion; conversion is controlled
  internally by Vjava_convert_matrix and Vjava_unsigned_conversion)
- because octave is not thread-safe, you must make sure the
  octave functions are called by a single thread at a time;
  this can be achieve from java world by using the synchronized
  keyword, for instance:

public class OctaveEngine
{
  static Object __lock__ = new Object();

  Object call_function (String name, Object[] args)
  {
    synchronized (__lock__)
    {
      // do something
    }
  }

  void eval_string (String cmd)
  {
    synchronized (__lock__)
    {
      // do something
    }
  }
}

Michael.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to