Raphael Collet wrote:
Dear Ashis,

The port only keeps a reference to the unbound tail of the stream. It does not keep alive all former messages that were sent.

Sorry for joining late, but, if you have a pointer to the beginning of the stream, then all the messages sent to that port will stay in the stream and not be garbage collected. is that right? for instance:

declare
S P
P = {NewPort S}
thread
   for Msg in S do
      {Browse Msg}
   end
end

That will keep the whole stream of messages because you can always access S.

An alternative code would be

declare
P
thread
   S
in
   P = {NewPort S}
   for Msg in S do
      {Browse Msg}
   end
end

on this second code you don't need to keep the whole stream, and then the garbage collector should be able to do its job.

cheers
Boriss



Cheers,
raph

On Thu, Mar 12, 2009 at 3:37 PM, Maity, Ashis K <[email protected] <mailto:[email protected]>> wrote:

    Thanks Torsten. That worked. Basically I am wiping my Dictionary
    whenever I send 'refresh'. But that means Port will grow infinitely. Not
    sure what effect it will have in production. How does the Port ever get
    garbage collected anyway?

    Thanks again,

    Ashis

    -----Original Message-----
    From: [email protected]
    <mailto:[email protected]>
    [mailto:[email protected]
    <mailto:[email protected]>]
    On Behalf Of Torsten Anders
    Sent: Wednesday, March 11, 2009 6:09 PM
    To: Mozart users
    Subject: Re: Global variable (Dictionary)

    Dear Ashis,

    The port simply forwards the data, so when you what to "clean" it is
    too late anyway.

    Instead, what you could do is send a special message like 'refresh'
    through the port whenever you want to wipe you log. Then, at the
    receiving side in the top-level space you can write yourself a
    program which, e.g., wipes your log file whenever the message
    'refresh' was sent.

    Best
    Torsten

    On Mar 11, 2009, at 8:13 PM, Maity, Ashis K wrote:

     > Thanks Filip. I am using it for kind of Logging purposes. But the
    port
     > is keeping up the logs (it's not really log for my case) from the
    last
     > run if I did not restart server. I want it to refresh the log (more
     > like
     > some diagnostic info in my case) at every run even I do not restart
     > the
     > server. Is there a simple way to clear the port?
     >
     > Ashis
     >
     > -----Original Message-----
     > From: [email protected]
    <mailto:[email protected]>
    [mailto:[email protected]
    <mailto:[email protected]>]
     > On Behalf Of Filip Konvicka
     > Sent: Wednesday, March 11, 2009 3:29 PM
     > To: [email protected] <mailto:[email protected]>
     > Subject: Re: Global variable (Dictionary)
     >
     > Hi,
     >
     >> I am getting another hang-up here. It appears that Port is not
     >> getting
     >> cleaned up in subsequent runs if the underlying process does not
    die.
     > Is
     >> there a simple way to reset the Port/Stream?
     >
     > I am accessing ports from spaces without problems. Remeber, when
    using
     > this from scripts, the semantics must not break the rules of spaces -
     > identical queries should always return identical results. (I used
    this
     > for referencing external static data and for caching of const
     > calculations.) Other meaningful usages are console I/O (output) and
     > logging.
     >
     > What exact problems are you experiencing? Isn't it that the server
     > thread just died? Be sure to fortify the thread using try...catch for
     > each message.
     >
     > HTH,
     > Filip
     >
     >
     >> Thanks so much,
     >>
     >> Ashis
     >>
     >> -----Original Message-----
     >> From: [email protected]
    <mailto:[email protected]> [mailto:users-boun...@mozart-
    <mailto:users-boun...@mozart->
     >> oz.org <http://oz.org>]
     >> On Behalf Of Maity, Ashis K
     >> Sent: Friday, February 27, 2009 3:50 PM
     >> To: Mozart users
     >> Subject: RE: Global variable (Dictionary)
     >>
     >> Thanks so much. I was able to solve my problem using Port.
     >>
     >> Ashis
     >>
     >> -----Original Message-----
     >> From: [email protected]
    <mailto:[email protected]> [mailto:users-boun...@mozart-
    <mailto:users-boun...@mozart->
     >> oz.org <http://oz.org>]
     >> On Behalf Of Torsten Anders
     >> Sent: Friday, February 27, 2009 1:11 PM
     >> To: Mozart users
     >> Subject: Re: Global variable (Dictionary)
     >>
     >> On Feb 27, 2009, at 4:29 PM, Raphael Collet wrote:
     >>> The error message says that you are trying to modify a stateful
     >>> entity from inside a computation space.  This is forbidden by the
     >>> language definition, because it breaks an essential assumption on
     >>> computations spaces: they cannot have side effects.  There is an
     >>> exception to the rule, however: you can send messages on ports.
     >>
     >> Besides, you could put a dictionary inside the script so it becomes
     >> local.
     >>
     >> Best
     >> Torsten
     >>
     >>>
     >>> Cheers,
     >>> raph
     >>>
     >>> On Fri, Feb 27, 2009 at 4:59 PM, Maity, Ashis K
     >>> <[email protected] <mailto:[email protected]>> wrote:
     >>> Hi everybody,
     >>>
     >>> How can I store data in a global variable (say in a Dictionary)
    in a
     >>> functor file so that I can export that data that can be accessed
     >>> from
     >>> another functor? Specifically, I am trying something like this
     >>> (seems
     >>> like this sandbox code doesn't even compile -- though actual code
     >>> does):
     >>>
     >>> functor
     >>> import
     >>> export
     >>> define
     >>>  Dict
     >>>
     >>>  Dict = {Dictionary.new}
     >>>
     >>>  proc{StoreInfo}
     >>>     {Dictionary.put Dict xx yy}
     >>>  end
     >>> end
     >>>
     >>>
     >>> The program either hangs or I get error -- "assignment of global
     >>> variable from local space" (it appears that I can do Dictionary.get
     >>> operation from local space). If I can not do it this way is there
     >>> another way I can store several key-value pairs that can be
     >>> accessed at
     >>> the end of run from another(Client) Functor?
     >>>
     >>> Thanks so much.
     >>>
     >>> Ashis
     >>>
     >
    ______________________________________________________________________
     >>
     >>> ___________
     >>> mozart-users mailing list                               mozart-
     >>> [email protected] <mailto:[email protected]>
     >>> http://www.mozart-oz.org/mailman/listinfo/mozart-users
     >>>
     >>> <ATT00001.txt>
     >>
     >>
     >
    ______________________________________________________________________

     > __
     >> _________
     >> mozart-users mailing list
     >> [email protected] <mailto:[email protected]>
     >> http://www.mozart-oz.org/mailman/listinfo/mozart-users
     >>
     >
    ______________________________________________________________________

     > __
     >> _________
     >> mozart-users mailing list
     >> [email protected] <mailto:[email protected]>
     >> http://www.mozart-oz.org/mailman/listinfo/mozart-users
     >>
     >
    ______________________________________________________________________

     > __
     > _________
     >> mozart-users mailing list
     > [email protected] <mailto:[email protected]>
     >> http://www.mozart-oz.org/mailman/listinfo/mozart-users
     >>
     >
     >
    ______________________________________________________________________

     > __
     > _________
     > mozart-users mailing list
     > [email protected] <mailto:[email protected]>
     > http://www.mozart-oz.org/mailman/listinfo/mozart-users
     >
    ______________________________________________________________________

     > ___________
     > mozart-users mailing list                               mozart-
     > [email protected] <mailto:[email protected]>
     > http://www.mozart-oz.org/mailman/listinfo/mozart-users

    ________________________________________________________________________
    _________
    mozart-users mailing list
    [email protected] <mailto:[email protected]>
    http://www.mozart-oz.org/mailman/listinfo/mozart-users
    
_________________________________________________________________________________
mozart-users mailing list [email protected] <mailto:[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
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to