Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Launch same actor two times,message can't reach the right method

Solved!
Go to solution

Hi all,i got a problem which is not found in the discunssions before,so pls give me a tip :

storm_k_0-1605748502272.png

The message is in a loop ,read client 's request .

 

I  built a actor , launch two times to do the same thing but face to different client , just like a framework ;

 

Launch one time works well , but two times works bad .

 

I debug the vis , found the message B(right) call the Method C (left) , not  call  the Method C (right) . I have already made the Method C reentrant.

 

Did i do something wrong?   

 

THKS!

0 Kudos
Message 1 of 11
(4,151 Views)

How do you distinguish between the "right" and the "wrong" method C? Are you sure that you are sending the Msg to the correct enqueer?

0 Kudos
Message 2 of 11
(4,100 Views)

Thank you for reply.

 

I used the "LabVIEW Task Manager" , open the method C (left and right in the picture ) .

 

The left method C  got the requests from client , but the right method C got request sometimes , most request were sent to the left method C 。

 

I upload an example which was published by NI

 

run the "Simple Actor Example.vi" , click the new 3 or more times , then open the "LabVIEW Task Manager" , like the picture below:

 
 

image.png

 

then open three vis(7340002,7340003,7340004),and add  probe on "Gauge Refnum" ,then you will find the  value of refnum handle is not a constant, it's floating.

image.png

 

I think the the  value of reference handle  should not be changed , if changed then you can't do the right thing to the right refnum, am i right ? THKS

0 Kudos
Message 3 of 11
(4,083 Views)

I think that the reason for this lies in the Do.vi. Reentrance is namely set to "shared clone reentrant".

 

https://zone.ni.com/reference/en-XX/help/371361R-01/lvconcepts/reentrancy/

 

If you would set Do.vi to "preallocated clone", the behavior would be as you expect. But I do not recommend this, because this would mean changing the Message.lvclass::Do.vi and thus the behaviour of the whole AF.

 

 

 

 

0 Kudos
Message 4 of 11
(4,072 Views)

yes,and if i set Do.vi to "preallocated clone" , the Do.vi is broken , it change the whole AF ,

 

so i have no idea

0 Kudos
Message 5 of 11
(4,067 Views)

Sorry, changing the reentrance type was a bad suggestion. Of course this is not possible because of dynamic dispatch terminals.

 

But, at what specific problem does LV's behavior bother you?

 

P.S.

A good idea is to save the original state of AF.lvlib before making global changes. I prefer to create a GIT repository in AF folder and to make the first commit before changing something.

0 Kudos
Message 6 of 11
(4,060 Views)

Hi , did u test the program i have uploaded? 

 

i think it shouldn't work like that,or the message is not needed

 

thks.

 

 

P.S.

GIT rock 😁

0 Kudos
Message 7 of 11
(4,056 Views)

Yes I did.

The behavior must be like this. Even if it is not intuitive. I don't understand which specific problem You have? Of course in this case You cannot use shift registers to store state between VI calls. Save the state in the member variables of your actor. Then it doesn't matter which clone of method C is called.

Message 8 of 11
(4,050 Views)

if the message reply  is wrong ,the next step is also wrong

0 Kudos
Message 9 of 11
(4,018 Views)
Solution
Accepted by topic author storm_k

There is no way to force a specific instance of a clone to execute in a particular actors message. Why do you need this behavior? There are some real use cases of this, but there is a good chance you don't actually need this - can you not just store the relevant state data in the actor's class data?

 

If you actually need this behavior, you can add a helper loop to actor core, and then make your method C a preallocated clone and call it from there. Of course you will need to add some communication mechanism from the actor message handling loop to this secondary loop - you could have your method C message just pass another message to the helper loop. Depending on what is happening in the helper loop, this can get pretty messy pretty quickly, which is why it is better to just do it in the actor's message handling loop if possible. 

0 Kudos
Message 10 of 11
(4,009 Views)