Closed dcy closed 8 years ago
This issue isn't an issue in turtle
. Rather, the problem is, as you say, a problem with linearization of initialization. You are generally not guaranteed that the processes are available, and even if you ask for them, you have no such guarantee.
The easiest solution to this problem is to move the refreshing inside the service process itself and handle it inside Mod:loop/4
. Turn the problem around by using the State
. If there is no token, make one, and then set the refresh timer, which will hit in handle_info/2
. If you need to use the same token in every child, create a process and register yourself to that process, so it can push out new tokens periodically to every subscriber (this can be done with gproc
rather easily).
A patch, which may be useful is to allow State
to be an initialization function, and make a PR on Turtle. This would allow you to run the initialization as if you were the target process in question.
Hi! I want to send info to subscriber to tell subscriber refresh state. In my code:
But it is asynchronous,
ChildSpecs = supervisor:which_children(Pid),
can not get all children(sometime [], sometime one child), so i can not send info to them all. Could you give me some advice about this issue?