In wich cases sameThreadExecutionContext adds runnables to a Batch?

Hi, I can’t see in wich cases akka.dispatch.ExecutionContexts.sameThreadExecutionContext will add runnables to the batch.
Considering any ExecutionContext that mixin BatchingExecutor I understand that this can occur if the same Thread from the EC queues more than one runnable before the batch is assigned to some Thread (could be the same that created the batch or another one from the ExecutionContext)

Example

  1. Thread A calls execute(runnable 1)
  2. Thread A lookups ThreadLocal[Batch] and is empty so it builds a Batch(runnable 1) and calls unbatchedExecute so its scheduled for execution (delegated to concrete classes)
  3. Thread A calls execute(runnable 2)
  4. Thread A lookups ThreadLocal[Batch] and it contains a batch so runnable 2 is added and now it looks like Batch(runnable 1, runnable 2)
  5. Batch is scheduled in Thread B, it runs it and that is it.

Now, in sameThreadExecutionContext Thread A will always run the Batch that was just created because when unbatchedExecute is called it will run in the same Thread.

  1. Thread A calls execute(runnable 1)
  2. Thread A lookups ThreadLocal[Batch] and is empty so it builds a Batch(runnable 1) and calls unbatchedExecute and runs the Batch
  3. Thread A calls execute(runnable 2)
  4. Same as (2)

If I understood correctly it doesn’t make any sense that sameThreadExecutionContext extends the BatchingExecutor trait, but there must be something that I’m not seeing. What is it?

Thanks.