Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7513487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:12:04+00:00 2026-05-30T00:12:04+00:00

all. I wrote the following simple code to test scala.actors._: // java version 1.7.0_02

  • 0

all.

I wrote the following simple code to test scala.actors._:

// java version "1.7.0_02"
// Scala code runner version 2.9.1.final
// Windows 7 Ultimate sp1 64-bit
import scala.actors._
import scala.collection.mutable.ArrayBuffer

object FutureResults extends App {
    val t1 = System.currentTimeMillis
    val (timeout, results) = (1000, new ArrayBuffer[Future[_]])
    for (i <- 0 until 3) results += new FutureResultsActor !! "execute"
    val options = Futures awaitAll (timeout, results:_*)

    val t2 = System.currentTimeMillis
    println("spent: %,d ms" format t2 - t1)
    options foreach println
    results foreach { i => println("isSet: %b" format i.isSet) }

    Thread sleep timeout

    val t3 = System.currentTimeMillis
    println("spent: %,d ms" format t3 - t1)
    options foreach println
    results foreach { i => println("isSet: %b" format i.isSet) }
}

class FutureResultsActor extends Actor {
    start
    override def act = react { case "execute" => Futures future "done" }
}

This produces:

spent: 1,092 ms
None
None
None
isSet: false
isSet: false
isSet: false

spent: 2,137 ms
None
None
None
isSet: false
isSet: false
isSet: false

Scaladoc of Futures#awaitAll says:

The result of a future that resolved during the time span is its value wrapped in Some.
The result of a future that did not resolve during the time span is None.

Is the timeout value too small? OK, I change the value to 5000 ms and try again:

spent: 5,070 ms
None
None
None
isSet: false
isSet: false
isSet: false

spent: 10,093 ms
None
None
None
isSet: false
isSet: false
isSet: false

All are None. Why?…

How to get Some(x) from the results of Futures#awaitAll?

Is there any incorrect code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:12:05+00:00Added an answer on May 30, 2026 at 12:12 am

    Indeed, they’re all timing out. Quite the tragedy! The reason: you’re not sending a reply from the actor—or at least not properly. I’m not really sure what “Futures future” is, but… my understanding is that the correct way to reply from within an actor is like so:

    class FutureResultsActor extends Actor {
      start
      override def act = react { case "execute" => reply("done") } // Use reply()!
    }
    

    Doing that got me this result:

    spent: 150 ms
    Some(done)
    Some(done)
    Some(done)
    isSet: true
    isSet: true
    isSet: true
    spent: 1,165 ms
    Some(done)
    Some(done)
    Some(done)
    isSet: true
    isSet: true
    isSet: true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I write the following code all the time to handle when the enter key
before this I wrote all jquery-code into main fail. Now I want to move
First of all, I wrote a simple php page, that picks up some variables
I am trying to write a simple function for windows that answers the following
everybody out there i write a very simple c code which is following: #include<stdio.h>
I have the following JUnit test. The method that I'm testing is quite simple,
The following line in my C program should provided All/Group/Owner read and write permissions
All, I need to write a regular expression to perform the following operations replace
I wrote a makefile: all: server client server: server.o des.o sha1.o /usr/local/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -o server
I wrote a tiny Bash script to find all the Mercurial changesets (starting from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.