Hi Roland
"sounds fishy, because actors do not expose methods, they only communicate
via message passing"
Agree. That is why I brought up this question.
Let me try with an example:
trait WorkerFSM[S, D] extends FSM[S, D]
case class MyType // which can have subclasses to define different types
trait ManagerFSM[S, D] extends FSM[S, D] {
// here, "_" implies any state as long the actor is started and not stopped
when(_){
case(Event(MyType, _)){
val myactor = context.actorOf[WorkerFSM[S,D]]("some name")
sender ! myactor
}}}
The code above does not compile as I wrote in GMAIL.
My problem is how to define "_" state as a wild card for all the states in
the state machine.
Thanks
Nader
On Wednesday, February 12, 2014 10:48:33 AM UTC+1, rkuhn wrote:
> Hi Nader,
>
> I think it would be best if you demonstrated your problem with code; the
> pseudo-code in the first email did not help me in this regard it seems.
>
> Just one thing: «The manager class (ManagerFSM) exposes a method» sounds
> fishy, because actors do not expose methods, they only communicate via
> message passing. The only thing you will see from the outside is the
> ActorRef, which supports nothing besides the `tell` operation (which `ask`
> is a variant of).
>
> Regards,
>
> Roland
>
> 12 feb 2014 kl. 09:08 skrev Nader Aeinehchi <[email protected]<javascript:>
> >:
>
> Hi again
>
> Let me explain it better. There are two options:
>
> 1. The manager class (ManagerFSM) exposes a method. Within the method, we
> call context.actorOf(....). But such method is part of the actor and NOT
> ActorRef. I do not know how to access such method from a client code.
> Perhaps, I misunderstand something here?
> 2. The second alternative is based on passing a Message to ManagerFSM.
> Here, I struggle with FSM state handling mechanism. I cannot see an option
> that sound "when(_){context.actorOf{...}".
>
> Perhaps, I misunderstand something here?
>
> In advance thank you very much.
>
> Best regards
> Nader
>
>
> On Tuesday, February 11, 2014 1:07:27 PM UTC+1, Akka Team wrote:
>
>> Hi Nader,
>>
>> it is not completely clear to me what you mean, especially by the “Does
>> not work” comment. Within an FSM you can create child actors just like in
>> any other actor, using “context.actorOf(…<props>…, name)”. Child actors
>> enjoy the same kind of encapsulation from all others—including from their
>> parent—so you will need to send messages to communicate with them.
>>
>> Regards,
>>
>> Roland
>>
>>
>>
>> On Mon, Feb 10, 2014 at 10:24 PM, Nader Aeinehchi <[email protected]>wrote:
>>
>>> Hi
>>>
>>> How can a child actor (which itself implements FSM) be created and added
>>> as a child to the context of a FSM actor?
>>>
>>> Suppose the following pseudocode:
>>>
>>> trait WorkerFSM[S, D] extends FSM[S, D]
>>>
>>> trait ManagerFSM[S, D] extends FSM[S, D] {
>>>
>>> // Does not work
>>> // Create some WorkerFSM actor and add it to the children of this
>>> ManagerFSM
>>> def actorOf[w <: WorkerFSM[S, D]](name: String): FSM[S, D]
>>> }
>>>
>>> The above does not work as only the reference to ActorRed is available
>>> to the client code. In other words, the client code cannot access the
>>> method "actorOf".
>>>
>>> One other alternative is to send messages to ManagerFSM. The problem is
>>> that FSM is coupled to the given state using the construct
>>> when(someState). But here, we would like ManagerFSM to create the child as
>>> long as the actor is preStarted and not stopped (as dictated by Actor's
>>> state diagram and not the fine-grained FSM state diagram).
>>>
>>> Any ideas?
>>>
>>> In advance, thank you very much.
>>>
>>> Nader
>>>
>>> --
>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>> >>>>>>>>>> Search the archives:
>>> https://groups.google.com/group/akka-user
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Akka User List" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> Akka Team
>> Typesafe - The software stack for applications that scale
>> Blog: letitcrash.com
>> Twitter: @akkateam
>>
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected]<javascript:>
> .
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> *Dr. Roland Kuhn*
> *Akka Tech Lead*
> Typesafe <http://typesafe.com/> – Reactive apps on the JVM.
> twitter: @rolandkuhn
> <http://twitter.com/#!/rolandkuhn>
>
>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.