In theory i only want to call updateGraph only when all LAFutures are
satisfied. But in the updateGraph they say that they arent satisfied?
I guess you need more code to know what i am talking about / reproduce
it?

it would help if you could put together a fully running sample, but IfI'm guessing your app right, you may want to change it a bit.Instead of pinging your comet and checking if work has been completedby all the Futures, you may want to do something like what I describehere:http://blog.fmpwizard.com/54204619and to decide when is the right time to send a "task complete "message to your comet actor, you can use a for comprehension , whichwill only reach the end if all Futures return a value.

I though that the "satisfaction"-count should get periodically
updated, but it isnt. Its just is "intialized" and than "gotcha".
Whats wrong with my brain?

Thanks in advance
Björn

On 18 Feb., 10:42, Diego Medina <di...@fmpwizard.com> wrote:
> it would help if you could put together a fully running sample, but If
> I'm guessing your app right, you may want to change it a bit.
> Instead of pinging your comet and checking if work has been completed
> by all the Futures, you may want to do something like what I describe
> here:http://blog.fmpwizard.com/54204619> and to decide when is the right time to send a "task complete "
> message to your comet actor, you can use a for comprehension , which
> will only reach the end if all Futures return a value.
>
> Hope that helps
>
> Diego
>

> I though that the "satisfaction"-count should get periodically
> updated, but it isnt. Its just is "intialized" and than "gotcha".

On localSetup, you set the Map weekResults,

then on the first Tick you call
if (satisfied) {

which always returns true because it is defined as

private def satisfied:Boolean = {
weekResults.size == satisfaction
}

and

weekResults.size is always 100 because it is init'ed in localSetup to hold one LAFuture per value of weeks

Unfortunately I can't rework your sample project right now (not enough time, sorry), but I can give you a few pointers of what I would do, and that may help you get going.

1- I wouldn't setup so many thing on localSetup, It is better to tell the CometActor ( and any other actor for that matter), to do things based on messages. In your case, what action is the one that would trigger the work> is it a button click?, a file upload?, if it is a button, have the button send a message to the cometActor to start start the work.

2- I wouldn't use a LAFuture, this is very personal, and others may disagree, but I prefer to send messages to actors, let them do the work and then send me another message once they are done. In your case you have one actor, the CometActor, that can send a message to the LiftActor that does the APIHandler, as both are actors, they can send messages to each other.

3- How would you know when all 100 items have been processed?
I would have a second LiftActor that has a
private var cnt: Int = 0 //or choose something that makes sens for your app

and then, the flow would be:

1- CometActor sends a message to the LiftActor APIHandler to do work (regular message using !
2- APIHandler does its work and once done sends a message to the Counter LiftActor
3- Counter LiftActor knows what the total number should be, so it increases the internal counter and compares it to the final number, once those match, it sends a message to the comet actor with the final result, oh right, when it increases the counter, it can send the comet a message saying it just finished that one item.

I dont know how to thank you. Your example code made me understand
much more of the way lift works. Thanks so much.

Sure thing. The code is mostly about how Actors work.

From your answer and the answers Diego provided a new question
raised.
I should use messages over LAFutures (they are not really a
replacement for another), shouldnt I?

Any time you want an Actor (CometActor or regular Actor) to do something, you should send a message to the Actor. The time it takes to process the message should be minimal as an Actor can process no other messages while it's processing a given message and blocking on external resources while servicing the message.

For your purposes, I'd use net.liftweb.util.Schedule to schedule lots of threads to go out and do lots of jobs against external resources. At the end of each thread's job, the thread should send a message to the Actor that spawned it with the information from the job. I wouldn't use Futures, I'd just spawn a bunch of threads and then send a bunch of messages.