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 8728581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:40:24+00:00 2026-06-13T08:40:24+00:00

I have this trait trait NonBlockingGoodness extends DataStore { import akka.dispatch.{ Future, ExecutionContext }

  • 0

I have this trait

trait NonBlockingGoodness extends DataStore {
  import akka.dispatch.{ Future, ExecutionContext }
  import akka.util.duration._
  import akka.util.Timeout

  implicit val ec = ExecutionContext.fromExecutorService(yourExecutorServiceGoesHere)
  implicit lazy val timeout = Timeout(5 seconds)     
}

I would like to access the ExecutionContext in another trait like such

trait AsyncGoodness extends NonBlockingGoodness {
  import akka.dispatch.Future

  def doSomething = {
    Future { "Future is the bomb." }
  }

However, I am getting the error

Could not find implicit value for parameter executor: akka.dispatch.ExecutionContext

UPDATED:
I figured out how to get the ExecutionContext in scope

trait AsyncGoodness extends NonBlockingGoodness {
  import akka.dispatch.ExecutionContext
  import akka.dispatch.Future

  def doSomething()(implicit executor: ExecutionContext) = {
    Future { "Future is the bomb." }
  }

However, I have a follow-up question. Since I may have more than 1 method in AsyncGoodness that uses ExecutionContext, is there a way to pass it in at the trait level instead of at each method like I did above.

  • 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-06-13T08:40:25+00:00Added an answer on June 13, 2026 at 8:40 am

    As it turns out, all I need to do is explicitly specify ec return type for the compiler to use it. Here’s the working code

    trait NonBlockingGoodness extends DataStore {
      import akka.dispatch.{ Future, ExecutionContext }
      import akka.util.duration._
      import akka.util.Timeout
    
      implicit val ec: ExecutionContext = ExecutionContext.fromExecutorService(yourExecutorServiceGoesHere)
      implicit lazy val timeout = Timeout(5 seconds)     
    }
    
    trait AsyncGoodness extends NonBlockingGoodness {
      import akka.dispatch.Future
    
      def doSomething = {
        Future { "Future is the bomb." }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this play framework 2 code (simplified): import formatters.json.IdeaTypeFormatter._ object IdeaTypes extends Controller
I have this situation object SuperHorribleLongName { trait X { private[SuperHorribleLongName] def internalGaga() :
Let's say I have this trait trait Ctx[C, V[_]] I am unable to construct
I have this class in scala trait PageComponent { protected var page:Page = _
Well, I have something like this: trait A class Serving(a: => A) object App
First of all i have trait: import _root_.com.thoughtworks.selenium._ import org.scalatest.matchers.ShouldMatchers import org.scalatest.matchers.ShouldMatchers._ trait SeleniumField
I have to use scala parser inside Play Framework application. import scala.tools.nsc._ trait Foo
I have this ul menu: <ul id=superfish-1> <li class=active-trail><a href=# class=sf-depth-1 active>Inicio</a></li> <li class=trail><a
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
Have this self-made slider: http://jsfiddle.net/wyc3P/4/ What it does: takes min and max values in

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.