On 08/04/2010 04:06 PM, HP Wei wrote:
Thank you your detailed description about system-entity being sited.
Here is another related issue.
I have a class which has some methods like this:
Pr = System.showInfo
class A_class
meth {M1 P ...}
{Pr "---checking"}
{Do_something ...}
{Pr "---Status: ..."}
end
end
Hi HP,
The System module has the same semantics for distribution as the OS module.
It's considered a local resource, and it will not be exported.
What you could do is to have Pr as an attribute of the object, and be able to
set it dynamically. Something like
meth setPr(PrintProc)
pr := PrintProc
end
like that, if you run the object at the machine where you created it, you will
do something like:
{Obj setPr(System.show)}
{Obj doSomething}
that will make all calls to attribute 'pr' become a call to System.show. If
instead you want to send the message to a remote site, one way to do it would
be as follows:
{Obj setPr(proc {$ Msg}
{Send P Msg}
end)}
where P is the remote port where you want to send the output.
I hope it helps.
cheers
Boriss
--------------------------------------------
I have this class running successfully on a machine A.
Now, I want it to run on machine B and watch the result on
machine A.
I understand that in general I could embed the class object
behind a stream/port entity on machine B.
Then I send a message from machine A to the port on machine B.
But what about those 'status-report-type print' statement
{Pr "status.."} inside those methods ??
Ideally, I want to see the status report on machine A's screen.
Any way to deal with this?
thanks
HP
On Wed, 4 Aug 2010, Wolfgang Meyer wrote:
Hi,
"OS" is a system module (although pre-imported in the Emacs OPI) and
as such is "sited". See
http://www.mozart-oz.org/documentation/dstutorial/node2.html#sited.entities
for an explanation.
.....
Another possibility (closer to your original example) is to distribute
a port instead of a function. In this way you can make sure that
"OS.system" is executed on the correct machine.
Machine A:
declare P T in
thread
Stream
in
P = {Port.new ?Stream}
for Command#Result in Stream do
Result = {OS.system Command}
end
end
{Connection.offerUnlimited P T}
{Show T} % cut-and-paste this output into the following
Machine B:
local P Result in
P = {Connection.take 'oz-ticket://...'} % copy ticket here
Result = {Port.sendRecv P "ls /a/path"}
{Inspect Result}
end
...
Cheers,
Wolfgang
_________________________________________________________________________________
mozart-users mailing list [email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users