Questions tagged [executioncontext]

Refers to concept of an environment where code is evaluated and executed. This refers to global and function execution contexts, how control is switched between, how binding occurs in context etc.

Execution context is abstract concept of programming and is closely related to executing code itself and order how it will executed (execution stack), how pointers to objects are created and used and how they're divided from each other. Because of abstract nature of concept itself Execution context is closely tied to particular implementation in programming languages (Javascript for example). Check related tags

Resources

Related tags

155 questions
6
votes
2 answers

JavaScript Scope and Execution Context

I am trying to understand JavaScript scope rules. What I have read in textbooks and the documentation is confusing. It seems to me that JavaScript is a statically (or lexically) scoped language - when trying to bind a variable name to a variable…
asterix
  • 163
  • 1
  • 3
  • 12
5
votes
1 answer

Play framework futures not being parallelised by default-dispatcher

I'm trying to test the ExecutionContext behaviour in a play app, and found that I'm not able to achieve any degree of parallelism when I'm using the default dispatcher either by calling as.dispatcher,…
4
votes
2 answers

ExecutionContext with RateLimiter

Suppose I have an HTTP client to call a server with a request rate limit, e.g. 1000 requests/ sec. I implemented a rate limiter in ExecutionContext like this: Created a bounded blocking queue with RateLimiter of Guava class…
Michael
  • 37,415
  • 63
  • 167
  • 303
4
votes
2 answers

Are function parameters in JavaScript hoisted?

function foo(a,b){ return a + b; } foo(1,2); Are function parameters hoisted? Does the variableEnvirnoment at the creation phase of the function execution context looks something like that : VE = { { 0 : undefined , 1: undefined,…
Abdou Bestmood
  • 465
  • 4
  • 14
4
votes
1 answer

Are dead threads replaced in an ExecutionContext and/or Java thread pool?

When a thread dies due to an exception, what happens to this thread? If it is inside a thread pool, does it spawn a new thread? I'm interested in what happens in scala ExecutionContext, but since an ExecutionContext wraps a java thread pool, I think…
vicaba
  • 2,676
  • 1
  • 22
  • 40
4
votes
1 answer

Configuring the Fork Join Thread Pool

I have a simple question on using the fork join thread pool. Here is a short example of what I'm using: executor = "fork-join-executor" # Configuration for the fork join pool fork-join-executor { # Min number of threads to cap factor-based…
joesan
  • 10,737
  • 20
  • 70
  • 176
4
votes
2 answers

How do I configure the shutdown policy for Scala ExecutionContexts?

I recently came across some odd behavior on a machine where maping a function that returns Future[T] was executing sequentially. This same problem does not occur on other machines: work is interleaved as one would expect. I later discovered that…
Dan Barowy
  • 2,202
  • 23
  • 35
4
votes
1 answer

How should I use ExecutionContext to provide flow of my own context?

Update: Found similar question. I want to implement some services following AmbientContext design pattern for our ASP.NET application. For example I need user name (like Thread.CurrentPrincipal) to be set once at the very beginning of the request…
Pavel Voronin
  • 11,811
  • 6
  • 54
  • 113
3
votes
0 answers

ExecutionContext with Rate and Concurrency Limits

Suppose I have a simple HTTP client with a naïve method like this: def httpGet(url: String)(implicit ec: ExecutionContext): Future[String] = Future { io.Source.fromURL(url).mkString } Suppose also I call it against a server with a rate and…
Michael
  • 37,415
  • 63
  • 167
  • 303
3
votes
1 answer

Why does adding a default parameter value change the behavior when modifying the arguments?

The first section is : var a = 1; function fn2(a) { arguments[0] = 20; var a = 22; console.log(a); console.log(arguments[0]); } fn2(a); The second section is: var a = 1; function fn2(a, b = 100) { arguments[0] = 20; …
Chor
  • 387
  • 3
  • 10
3
votes
1 answer

Getting ExecutionContext Globally in Azure Function App

I have function Apps, and in a helper class that is going to prepare a file and store it for me i want to read the project file I tried many ways, such as (AppDomain, AppContext, .... etc) and many others, and as it is serverless, the program.cs is…
3
votes
1 answer

Execution context and object in JavaScript

There's something about object, execution context in JS that I don't understand. When we create an object, does it create an execution context ? since an execution context is created when a function is invoked. And if it doesn't, so the object is…
Quoc-Hao Tran
  • 1,012
  • 2
  • 11
  • 18
3
votes
1 answer

scala.concurrent.Future.onSuccess execution time on different ExecutorService

I wanted to control the number of threads in ExecutionContext. So I created a instance of ThreadPoolExecutor and then created ExecutionContext from it. And I created some Futures and attached onSuccess callbacks on them. I expected each onSuccess…
jyshin
  • 539
  • 1
  • 5
  • 14
3
votes
1 answer

Is ExecutionContext cleared after the thread is returned to thread pool?

It is written in the docs: When the thread pool reuses a thread, it does not clear the data in thread local storage or in fields that are marked with the ThreadStaticAttribute attribute. Therefore, when a method examines thread local storage…
Pavel Voronin
  • 11,811
  • 6
  • 54
  • 113
2
votes
1 answer

Counting the number of threads in an ExecutionContext

Suppose I want to know how many threads there are in a given ExecutionContext. So I am writing a function like this def count(implicit ec: ExecutionContext): Int = { val promise = Promise[Unit] val counter = new AtomicInteger(0) for (_ <- 0 to…
Michael
  • 37,415
  • 63
  • 167
  • 303
1
2
3
10 11