On Tue, Nov 17, 2009 at 12:34 PM, braver <[email protected]> wrote:

>
> On Nov 17, 2:26 pm, David Pollak <[email protected]>
> wrote:
> > There's no such thing as "shut down" for Lift Actors.  They are like any
> > other object in your JVM.  They respond to messages and when there are no
> > more references to them, they get garbage collected.
>
> I'm probably belaboring the point or missing a koan, but that was
> exactly my wonderment, as to where and how do I declare the reader and
> writer as Lift actors in order for them to go out of scope when I
> desire.


Just like any other object in your application.  Do you worry about a String
or a Map or a List being garbage collected?  Does it matter?


>  I'll stick to my app even though it might not be ideal for
> actors, to try to understand how and whether it can be done.
>
> E.g.,
>
> def main(...) {
>
>  val reader = new ReaderLiftActor(inputFileName,...)
>  val writer = new WriterLiftActor(...)
>
> }
>
> The reader slurps all lines in the input file and starts feeding the
> writer, one my one, via message.  Now what?  OK, so I have to leave
> scope.  Would I do something like,
>
> def main(...) {
>
>  var exit: Boolean = false
>
>  /* some scope prefix, like while (!exit) ? */ {
>    val reader = new ReaderLiftActor(inputFileName,...) // affects
> exit?
>    val writer = new WriterLiftActor(...)
>    // some waiting?
>  } // end of scope
>
>  // yay!  may go home
> }
>
> Is there an idiom in Lift to create the actors in scopes for the job,
> then let them slip into the night?
>

Yes, the idiom is the same idiom that you use to create any other JVM object
and let it slip into the night:

to create:
val obj = new Object

to slip into the night:

exit the scope of val obj and if the reference wasn't passed to and retained
by any other object in the system, it will be garbage collected.

But as I've said, you should not use Actors (Scala or Lift) for IO.  If you
want to do IO, use threads and use thread.join to wait until the thread has
terminated.

Thanks,

David


> Cheers,
> Alexy
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<liftweb%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=.
>
>
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=.


Reply via email to