try to assign ourselves an executor with work available
485342
private boolean selfAssign()
    {
        // if we aren't permitted to assign in this state, fail
        if (!get().canAssign(true))
            return false;
        for (SEPExecutor exec : pool.executors)
        {
            if (exec.takeWorkPermit(true))
            {
                Work work = new Work(exec);
                // we successfully started work on this executor, so we must either assign it to ourselves or ...
                if (assign(work, true))
                    return true;
                // ... if we fail, schedule it to another worker
                pool.schedule(work);
                // and return success as we must have already been assigned a task
                assert get().assigned != null;
                return true;
            }
        }
        return false;
    }
1233713
public CallOptions withExecutor(@Nullable Executor executor) {
    CallOptions newOptions = new CallOptions(this);
    newOptions.executor = executor;
    return newOptions;
  }
942035
protected <T> Future<T> invokeSubmit(ExecutorService executor, Callable<T> task) {
    return executor.submit(wrapTask(task));
  }
411583
@Validate
    public void start() {
        Configuration conf = configuration.getConfiguration("pools");

        createExecutor(ManagedExecutorService.SYSTEM,
                conf != null ? conf.getConfiguration("executors." + ManagedExecutorService.SYSTEM) : null);
        createScheduler(ManagedScheduledExecutorService.SYSTEM,
                conf != null ? conf.getConfiguration("schedulers." + ManagedScheduledExecutorService.SYSTEM) : null);

        if (conf != null) {
            createOtherExecutors(conf.getConfiguration("executors"));
            createOtherSchedulers(conf.getConfiguration("schedulers"));
        }
    }
428114
def delegate(self, fn, *args, **kwargs):
        """"""
        return self.subexecutor.submit(fn, *args, **kwargs)
721134
def delegate(self, fn, *args, **kwargs):
        """"""
        return self.subexecutor.spawn(fn, *args, **kwargs)
66281
function IPromise(executor) {
  const self = this;
  if (!Shared.isObject(self)) {
    throw new TypeError('IPromise must be a object');
  }
  if (!Shared.isFunction(executor)) {
    throw new TypeError('executor must be a function');
  }
  this.currentState = Shared.PENDING; // default
  this.valOrErr = null; // if fulfilled result to it else rejected error to it
  this.onFulfilledCallback = []; // if current state PENDING push the func wait onFulfilled to exec
  this.onRejectedCallback = []; // if current state PENDING push the func wait onRejected to exec

  // safely executor when executor not a empty function
  if (Shared.noop !== executor) {
    safelyToExecutor(self, executor);
  }
}
591904
private static void doExecute(Executor executor, Runnable runnable) {
    try {
      executor.execute(runnable);
    } catch (Throwable th) {
      log.log(Level.SEVERE, "Failed to execute PingCallback", th);
    }
  }
210587
def worker_allocator(self, async_loop, to_do, **kwargs):
        
        d = kwargs
        threading.Thread(
            target=self._asyncio_thread, args=(async_loop, to_do, d)
        ).start()
320482
function promise_executor(resolve, reject) {
	var worker = this[0], order = this[1]
	Promise.resolve(promise_static_member(worker, order) || order)
		.catch(kickTaskOrder.bind(this)) // yes, the <this> is prebind array
		.then(resolve, reject)
}
1110596
def load_executor(self, executor_name):
        """"""
        executor_name = executor_name + '.prepare'
        module = import_module(executor_name)
        return module.FlowExecutorPreparer()
521519
def set_executor(self, executor: futures.Executor):
        
        self.loop.set_default_executor(executor)
        self._func_executor = executor
        return True
1117887
public void perform(TaskRequest req, TaskResponse res) {
         final String poolAttributeName = (String) this.attributeNamePhrase.evaluate(req, res);
         final boolean useExisting = Boolean.valueOf((String) this.useExistingPhrase.evaluate(req, res));
         
         final ExecutorService executorService;
         final boolean usingExisting;
         if (useExisting && req.hasAttribute(poolAttributeName)) {
             // Try using an existing pool
             executorService = (ExecutorService) req.getAttribute(poolAttributeName);
             usingExisting = true;
         }
         else {
             //No existing pool or configured to ignore it, create a new pool
             final int threads = Integer.parseInt((String) this.threadsPhrase.evaluate(req, res));
             final int queueRatio = Integer.parseInt((String) this.queueRatioPhrase.evaluate(req, res));
             
             if (this.log.isDebugEnabled()) {
                 this.log.debug("Creating ThreadPoolExecutor with " + threads + " threads and queue space of " + (threads * queueRatio));
             }
             
             executorService = this.createExecutorService(threads, queueRatio);

             usingExisting = false;
         }
         
         try {
             //Provide the pool as a response attribute
             res.setAttribute(poolAttributeName, executorService);
             
             //Delegate to sub-task execution
             this.performSubtasks(req, res);
         }
         finally {
             //If using an existing pool it should not get shutdown here
             if (usingExisting) {
                 return;
             }
             
             //If shutdown already it is due to a child task, likely from a fail-fast ConcurrentTask handling an exception
             if (executorService.isShutdown()) {
                 throw new IllegalStateException("The ExecutorService was shutdown by a child task. This is likely due to an exception inside of a ConcurrentTask. Check the logs for information about the failed ConcurrentTask");
             }
             
             //Cleanly shutdown the pool
             executorService.shutdown();
             
             //Wait for all tasks to complete
             try {
                 executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
             }
             catch (InterruptedException e) {
                 this.log.warn("Interrupted while waiting for thread pool to shutdown", e);
             }
         }
     }
304078
private BlockingExecutor getExecutor(Work work)
   {
      BlockingExecutor executor = shortRunningExecutor;
      if (longRunningExecutor != null && WorkManagerUtil.isLongRunning(work))
      {
         executor = longRunningExecutor;
      }

      fireHintsComplete(work);

      return executor;
   }
45566
function safelyToExecutor(self, executor) {
  let done = false;
  try {
    executor(
      function(result) {
        if (done) return;
        done = true;
        doResolve.call(self, result);
      }, // doResolve
      function(error) {
        if (done) return;
        done = true;
        doReject.call(self, error);
      } // doReject
    );
  } catch (error) {
    if (done) return;
    done = true;
    doReject.call(self, error);
  }
}
1136744
function addExecutor(name, executor) {
  if (this._executors[name]) throw new Error('executor "' + name + '" is already defined');
  this._executors[name] = executor;
}
1129921
function internal_execute_task(taskDef) {
	// var worker = this[0], args = this[1];
	var taskOrder = mix(makeTaskOrder(taskDef), this[1]);
	var executor = promise_executor.bind([this[0], taskOrder]);
	return new Promise(executor)
}