scala - program hangs when using multiple futures with multiple remote actors -


I start two remote actors on a host who fixes whatever gets sent to them. Then I will make another actor who will send some actors (using !!) to keep a list of future items for both actors and these artists. Then I am getting a loop on this list for every future result. The problem is that most futures do not return at all times, even thought that the actor claims he has sent the answer. This problem is randomly, sometimes it gets through the entire list, but most of the time it gets stuck at any time and hangs indefinitely.

Here is some code that creates a problem on my machine:

Sync.ca:

Import Slaël.actors. Actors.actor._size slaella.actors.import import scale.actors.remat RemoteActure Import Scala Actors.remote.RemoteActor._Object Sync {ARG: array [string]): unit = {new remote sync ("node 0-0-0", 43001). Start () "New" ("node 0 3", 43001) start ()}} class RemoteSync (name: string, port: IT) extends actor {def act () {println (name + "starts) "Exit" (cause, reason) = & gt; {exit (}} case message = & gt; Msg] Answer: "trap" = true live (port) register (symbol (name), auto responder {exit} Source:
  

Import Slaël.Actors.Act Import Slay A. Actors.Act ._Image ScalaActors.Rom.Node; Import ScalaActorsRemote RemoteActer Import Scale.actors.remote RemoteActor.Object Source {DEAF MAIN (AGR: ARE [string]): unit = { Well pear = node ("127.0.0.1", 43001) Well source = new remote source (peer) source. Start ()}} class remotes a source (peer: node) actor {def Act () {trapExit = true Live (43001) register (symbol ("source"), itself) val sync = list (sync and left) ; - sink; I & lt; - (Select) (Peer, symbol ( "node 0 0-0")), select (Peer, symbol ( "node 0 0")) sink. 0 to 20) Yield Sink !! "Hello" + I futures Foreach (f = & gt; println (f ())) exit ()}}

What am I doing?

I am guessing your problem is due to this line:

  Future Foreach (f = & gt; Println (f ()))  

In which you loop through all your futures and in turn, block on each, waiting for its result. Preventing futures is usually a bad idea and should be avoided. Specify an action to complete when future results are available to try it instead:

  Future Foreach (f = & gt; f.foreach (r = & gt; println (r)))  

This is an alternative way to say that to understand with one: < For future, the future of the blocking of futures and how monetary futures can be overcome by the future of the future. An excellent primer for


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -