Hi there,

returning to an offer at the beginning of January w.r.t asking questions
about the new 4.0 APIs (attached).

Having gone through the new C++ APIs maybe the best way to express
questions would be to ask for commented nutshell (= very short programs)
API examples. Possible solutions would mostlikely help clarify a *lot*
of questions right away. Therefore I enclosed two requests for nutshell
API examples, which I think would help understand quite a few of the
APIs and how they play together.

In the context of the requested nutshell examples I tried to supply at
least the ooRexx part of the question, by creating two small
multithreaded nutshell ooRexx programs with which or from which the
interfacing should occur.

Regards,

---rony


Rick McGuire wrote:
> On Sun, Jan 4, 2009 at 6:33 PM, Rony G. Flatscher
> <rony.flatsc...@wu-wien.ac.at> wrote:
>   
>> Bonjour Jean-Louis,
>>
>> I confirm that the current distribution built with ooRexx 3.2 works well
>> with ooRexx 4, after the changes made by Rick today.
>> All the scripts in samples run without problem, from rexx or from java.
>>
>> That's really great news!
>>
>> Only Snippet108.rex is not running, I suppose I don't have SWT.
>>
>> Yes, you would need to get it from <http://www.eclipse.org/swt/>. After
>> that, all of Eclipse's swt-gadgets are available to you (and transcribing
>> the Java snippets to ooRexx using BSF4Rexx is quite straight-forward) ...
>>
>> Even not a little bug to shake out :-)
>>
>> :-)
>>
>> Nevertheless, your work on making BSF4Rexx compile with ooRexx 4.0 is highly
>> appreciated as it will get incorporated (after the ski-seminar which starts
>> this week, our winter term goes on until the end of January over here),
>> before starting one long-outstanding/planned enhancement to BSF4Rexx which
>> is only possible with ooRexx 4.0, which will allow for call backs. [For that
>> I will have to study the addressing of specific running ooRexx interpreter
>> instances as well as ooRexx threads and addressing ooRexx objects therein.]
>>     
>
> And all questions about this can be asked here.
>
> Rick
>
>   
>> Regards,
>>
>> ---rony
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Oorexx-devel mailing list
>> Oorexx-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>>
>>
>>     
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Oorexx-devel mailing list
> Oorexx-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>
>   



Purpose: demonstrate how to start interpreter instance(s), load and run Rexx 
programs,
         and change .local entries from the different interpreter instances, 
and also
         create an instance of a (non public) class to run concurrently to the 
Rexx
         program's ones

In order to be easily understood it would be probably very helpful, if the 
following
(as short as possible) documented nutshell programs would be created:


a) Nutshell program 1a)

        - demonstrate how to create an interpreter instance:

          -> create an interpreter instance

        - demonstrate how to load and run a multithreaded Rexx program:

          -> load and run a multithreaded Rexx program (enclosed, see bottom)


b) Nutshell program 1b): use the code from 1a) add the following features to it

        - demonstrate changing the value of an entry in .local (which is 
interpreter
          instance dependent) :

          -> change the entry named "INTERPRETER.INFO" stored in .local to "[# 
1]" to
             reflect that that program is running for the interpreter instance 
# 1

        - demonstrate how to retrieve a (non-public) class object, create an 
instance
          of it and send it a message; demonstrate how to retrieve an object 
from .local
          to supply it as one of the arguments to the message:

          -> create an instance of the class "Worker", retrieve the object 
referenced
             by ".BUFFER" (stored in .local), invoke the "write" method on the 
worker
             object supplying arguments, this should be the C++ equivalent of 
ooRexx':

                 .worker~new~write(.buffer, "from_C++_1", 7)


c) Nutshell program 1c): use the code from 1b) add the following features to it

        - demonstrate how one can create two instances of the interpreter in the
          same process, run the same Rexx program (see below), changing infos in
          .local accordingly


        - demonstrate changing the value of an entry in .local (which is 
interpreter
          instance dependent) :

          -> change the entry named "INTERPRETER.INFO" stored in .local to "[# 
1]"
             ("[# 2") to reflect that that program is running for the 
interpreter
             instance # 1 (# 2)

        - demonstrate how to retrieve a (non-public) class object, create an 
instance
          of it and send it a message; demonstrate how to retrieve an object 
from .local
          to supply it as one of the arguments to the message, do this for each
          interpreter instance:

          -> create an instance of the class "Worker", retrieve the object 
referenced
             by ".BUFFER" (stored in .local), invoke the "write" method on the 
worker
             object supplying arguments, this should be the C++ equivalent of 
ooRexx':

                 .worker~new~write(.buffer, "from_C++_?", 7)

          -> "?" in the above should be replaced by "1" or "2", depending on the
             interpreter instance that is addressed.


---

Multithreaded Rexx program, which should be used by the aforementioned C++ 
nutshell
examples to execute and to interact with:

------------------ cut here ------------------
   -- info of interpreter instance running, maybe changed by C++ nutshell
.local~interpreter.info="[# 0]"

a=.worker~new     -- used to read & write messages to buffer
b=.worker~new     -- used to write messages to buffer

.local~buffer=.fifo~new    -- buffer that gets shared

a~write(.buffer, "from_a", 5)  -- write 5 messages
b~write(.buffer, "FROM_B", 6)  -- write 6 messages

   -- how much got written asynchroneously so far?
say .interpreter.info "... 'a' has written" a~i "messages so far"
say .interpreter.info "... 'b' has written" b~i "messages so far"

   -- let the main program sleep a little bit
sleepTime=.001
say .interpreter.info "sleeping" sleepTime "seconds"
call sysSleep sleepTime

   -- how much got written asynchroneously so far?
say .interpreter.info "... 'a' has written" a~i "messages so far"
say .interpreter.info "... 'b' has written" b~i "messages so far"

   -- now read asynchroneously from the buffer
say .interpreter.info "... now starting to read from buffer"
a~read(.buffer)                -- read all messages from buffer
say .interpreter.info "--> main program finished @" .DateTime~new~string


/* Read and write messages from/to given buffer asynchroneously */
::class Worker
::method init class
  expose activeWriter
  activeWriter=0  -- number of active writers

::attribute activeWriter class

::method init
  expose i
  i=0          -- initialize variable

::attribute i get unguarded

::method write
  expose i
  use arg buffer, msg, repetitions
  self~class~activeWriter+=1    -- increase counter
  REPLY        -- start asynchroneous execution
  do i=1 to repetitions
    buffer~write(i msg "@" .DateTime~new~string)
    call sysSleep random(1, 9)/1000
  end

  buffer~write("--> writing message ["msg"] finished @" .DateTime~new~string)
  self~class~activeWriter-=1    -- decrease counter

::method read
  use arg buffer
  REPLY        -- start asynchroneous execution
  call sysSleep  .1   -- wait a bit before starting to read
  do while buffer~items>0 | self~class~activeWriter>0  for 50
    msg=buffer~read
    say .interpreter.info "just read from buffer: ["|| buffer~identityHash"] 
message: ["msg"]"
  end
  say .interpreter.info  "--> read(): finished @" .DateTime~new~string



/* FIFO buffer, backed by a Rexx .Queue */
::class FIFO

::method init
  expose buffer
  buffer=.queue~new

::method write
  expose buffer
  use arg tmp
  buffer~queue(tmp)

::method read
  expose buffer
  return buffer~pull

::method items
  expose buffer
  return buffer~items

------------------ cut here ------------------


Purpose: demonstrate how to create an external function that is able to interact
         with the method's variable pool (displaying all variable names) and
         with the object's attributes (displaying all object variable names,
         changing the value of one object variable); if possible, the function
         should also display the hashid of the object for which the method got
         invoked, as well as the name of the invoked method


Nutshell program:

        - demonstrate how to create an interpreter instance:

          -> create an interpreter instance

        - demonstrate how to load and run a multithreaded Rexx program:

          -> load and run a multithreaded Rexx program (enclosed, see bottom)

        - demonstrate how to define an external routine named "externalRoutine"

          -> define the external routine in the nutshell code

        - demonstrate how to interact with the variable pool, if possible

          -> get the variable pool of the running method and display the
             names (maybe "SLEEPTIME" ?)

        - demonstrate how to interact with the object variable pool, if possible

          -> get the object variable pool of the running method and display the
             names (maybe "NAME", "MYDATA"?)

        - demonstrate how to change an object variable's value, if possible

          -> get the object variable "MYDATA", add the string " from C++ @ " and
             the string value of a newly created instance of .DateTime and save 
it

        - demonstrate how to get at the object for which the method runs and
          also how to invoke a method on that object, if possible

          -> get a reference to the object and display its "identityHash", by
             invoking this method and display its result

        - demonstrate how to get at the method's name, if possible

          -> get the method's name and display it


---

Multithreaded Rexx program, which should be used by the aforementioned C++ 
nutshell
examples to execute and to interact with (of course the ::requires-directive 
needs to
be adjusted):

------------------ cut here ------------------

do i=1 to 5
   o=.worker~new("object #" i)
   o~doSomething
end

-- ::requires --> require external library which contains "externalRoutine"

::class worker
::method init
  expose mydata name
  parse arg name
  mydata=.DateTime~new~string

::method doSomething
  expose mydata name
  reply
  myData=.dateTime~new~string
  sleepTime=random(1,10, time("f")~right(12)~left(9))/1000
  say name": myData=["myData"] before, sleeping:" sleepTime "seconds"
  call sysSleep sleepTime
  call externalRoutine     -- <== call into an external routine
  say name": myData=["myData"] after calling 'externalRoutine'"
------------------ cut here ------------------
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to