Call from any thread
167486
def recv_rpc(self, context, payload):
        """"""
        logger.debug("Adding RPC payload to ControlBuffer queue: %s", payload)
        self.buf.put(('rpc', (context, payload)))
        with self.cv:
            self.cv.notifyAll()
198730
def __postCallAction(self, event):
        
        aThread = event.get_thread()
        retval  = self._get_return_value(aThread)
        self.__callHandler(self.__postCB, event, retval)
546356
def batch_call(self, calls):
        """"""
        req = self.protocol.create_batch_request()

        for call_args in calls:
            req.append(self.protocol.create_request(*call_args))

        return self._send_and_handle_reply(req)
1277328
protected void startUnaryCalls(int callsPerChannel,
                                 final AtomicLong counter,
                                 final AtomicBoolean done,
                                 final long counterDelta) {
    for (final ManagedChannel channel : channels) {
      for (int i = 0; i < callsPerChannel; i++) {
        StreamObserver<ByteBuf> observer = new StreamObserver<ByteBuf>() {
          @Override
          public void onNext(ByteBuf value) {
            counter.addAndGet(counterDelta);
          }

          @Override
          public void onError(Throwable t) {
            done.set(true);
          }

          @Override
          public void onCompleted() {
            if (!done.get()) {
              ByteBuf slice = request.slice();
              ClientCalls.asyncUnaryCall(
                  channel.newCall(unaryMethod, CALL_OPTIONS), slice, this);
            }
          }
        };
        observer.onCompleted();
      }
    }
  }
827013
def on_call(receiver, dot, method)
      if rcv = resolve_receiver(receiver)
        method_call(method, [rcv])
      end
       
      keep_walking(receiver)
    end
1257845
def call(self, method, args={}, retry=False, retry_policy=None,
             ticket=None, **props):
        """"""
        ticket = ticket or uuid()
        reply_q = self.get_reply_queue(ticket)
        self.cast(method, args, declare=[reply_q], reply_to=ticket, **props)
        return self.AsyncResult(ticket, self)
655293
function executeHooks(data, allHooks, checkHooks, creationMode) {
    var hooksToCall = creationMode ? allHooks : checkHooks;
    if (hooksToCall) {
        callHooks(data, hooksToCall);
    }
}
833057
def instance_thread_global(name, value = nil)
      sc = class << self
        extend DSLKit::ThreadGlobal
        self
      end
      sc.thread_global name, value
      self
    end
91569
def call_repeatedly(func, interval, *args, **kwargs):
    
    main_thead = threading.current_thread()
    stopped = threading.Event()

    def loop():
        while not stopped.wait(interval) and main_thead.is_alive():  # the first call is in `interval` secs
            func(*args, **kwargs)

        return

    timer_thread = threading.Thread(target=loop, daemon=True)
    timer_thread.start()

    atexit.register(stopped.set)

    return timer_thread, stopped.set
1231039
def call(message, captures, arguments)
      bargs = captures + arguments

      thread = Thread.new {
        @bot.loggers.debug "[New thread] For #{self}: #{Thread.current} -- #{@thread_group.list.size} in total."

        begin
          if @execute_in_callback
            @bot.callback.instance_exec(message, *@args, *bargs, &@block)
          else
            @block.call(message, *@args, *bargs)
          end
        rescue => e
          @bot.loggers.exception(e)
        ensure
          @bot.loggers.debug "[Thread done] For #{self}: #{Thread.current} -- #{@thread_group.list.size - 1} remaining."
        end
      }

      @thread_group.add(thread)
      thread
    end
276648
def call(self, fn, *args, **kwargs):
        
        return self.default_call_chain.call(fn, *args, **kwargs)
792346
private int doInvoke() {
        int s; Thread t; ForkJoinWorkerThread wt;
        if ((s = doExec()) >= 0) {
            if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
                s = (wt = (ForkJoinWorkerThread)t).pool.awaitJoin(wt.workQueue,
                                                                  this);
            else
                s = externalAwaitDone();
        }
        return s;
    }
481435
private static <T> ThreadContext<T> getCurrentThreadContext(ThreadContext<T> threadContext)
    {
        return ((ThreadContextImpl<T>) threadContext).get();
    }
119806
private void joinAllThreads() {
        Iterator iter = registeredWachdogs.values().iterator();
        while (iter.hasNext()) {
            Watchdog th = (Watchdog) iter.next();
            boolean isJoining = true;
            if (!th.isAlive() && log.isDebugEnabled()) {
                log.debug("Thread " + th + " finished");
            }
            while (th.isAlive() && isJoining) {
                try {
                    th.getThread().join();
                    isJoining = false;
                    if (log.isDebugEnabled()) {
                        log.debug("Thread " + th + " joined and finished");
                    }
                } catch (InterruptedException e) {
                }
            }
        }
    }
638143
function any() {
      var args = [].slice.apply(arguments);
      args.unshift(this.event);
      task.emit.apply(task, args);
    }
1021523
def threaded(func):
    

    def dec(self, *args, **kwargs):
        thread.start_new_thread(func, (self, ) + args, kwargs)

    return dec
24033
def call_async(func):
    """"""

    @wraps(func)
    def wrapper(self, *args, **kw):
        """Wraps instance method to be called on loop thread"""

        def call():
            """Calls function on loop thread"""
            try:
                func(self, *args, **kw)
            except Exception:
                logger.exception(
                    "failed to call async [%r] with [%r] [%r]", func, args, kw
                )

        self.loop.call_soon_threadsafe(call)

    return wrapper