Decide whether to borrow or take one quota from
        the reservoir. Return ``False`` if it can neither
        borrow nor take. This method is thread-safe.
187647
def borrow_or_take(self, now, can_borrow):
        
        with self._lock:
            return self._borrow_or_take(now, can_borrow)
1173117
def pool(n=None, dummy=False):
    

    if dummy:
        from multiprocessing.dummy import Pool
    else:
        from multiprocessing import Pool
    if n is None:
        import multiprocessing
        n = multiprocessing.cpu_count() - 1

    return Pool(n)
1262272
def TryConsume(self, token):
    
    if self.token == token:
      self.NextToken()
      return True
    return False
799035
def _should_get_another_batch(self, content):
    
    if ('max-keys' in self._options and
        self._options['max-keys'] <= common._MAX_GET_BUCKET_RESULT):
      return False

    elements = self._find_elements(
        content, set([common._T_IS_TRUNCATED,
                      common._T_NEXT_MARKER]))
    if elements.get(common._T_IS_TRUNCATED, 'false').lower() != 'true':
      return False

    next_marker = elements.get(common._T_NEXT_MARKER)
    if next_marker is None:
      self._options.pop('marker', None)
      return False
    self._options['marker'] = next_marker
    return True
1227030
protected int chooseMeanCapacity(int size, double minLoad, double maxLoad) {
    return nextPrime(Math.max(size+1, (int) ((2*size / (minLoad+maxLoad)))));
  }
831839
def consume(self, amount=1):
        """"""
        # First, cleanup old stock
        current = self.leak()

        if current + amount > self.capacity:
            return False

        self._incr(amount)
        return True
315742
def pool(self):
        
        if self._pool is None:
            self._pool = ThreadPool(self.pool_threads)
        return self._pool
618459
def pop_one(self, priority=None):
        
        with self.lock:
            if not priority:
                priority = self.highest_entry()
            if self.closed:
                return [THREAD_STOP]
            elif not self.queue:
                return None
            else:
                v =self.pop(priority=priority)
                if v is THREAD_STOP:  # SENDING A STOP INTO THE QUEUE IS ALSO AN OPTION
                    self.closed.go()
                return v
1373949
private QuotaValue getQuotaValue(final CacheKey key) throws UnknownQuotaLimitException
   {
      QuotaValue quotaValue = SecurityHelper.doPrivilegedAction(new PrivilegedAction<QuotaValue>()
      {
         public QuotaValue run()
         {
            return (QuotaValue)cache.withFlags(Flag.FORCE_WRITE_LOCK).get(key);
         }
      });
      if (quotaValue == null)
      {
         throw new UnknownQuotaLimitException("Quota was not set early");
      }

      return quotaValue;
   }
10238
protected int chooseShrinkCapacity(int size, double minLoad, double maxLoad) {
    return nextPrime(Math.max(size+1, (int) ((4*size / (minLoad+3*maxLoad)))));
  }
596887
boolean takeTaskPermit()
    {
        while (true)
        {
            long current = permits.get();
            int taskPermits = taskPermits(current);
            if (taskPermits == 0)
                return false;
            if (permits.compareAndSet(current, updateTaskPermits(current, taskPermits - 1)))
            {
                if (taskPermits == maxTasksQueued && hasRoom.hasWaiters())
                    hasRoom.signalAll();
                return true;
            }
        }
    }
175173
def take(self):
        
        with self._lock:
            now = int(time.time())

            if now != self.this_sec:
                self.used_this_sec = 0
                self.this_sec = now

            if self.used_this_sec >= self.traces_per_sec:
                return False

            self.used_this_sec = self.used_this_sec + 1
            return True
801009
def unpersist(self, blocking=False):
        
        self.is_cached = False
        self._jdf.unpersist(blocking)
        return self
1289329
def on_threadpool?
      tp = nil

      @mutex.synchronize do
        return false unless @threadpool # you can't dup nil
        tp = @threadpool.dup
      end

      tp.respond_to?(:include?) and tp.include?(Thread.current)
    end
1126240
private boolean move0(PoolChunk<T> chunk) {
        if (prevList == null) {
            // There is no previous PoolChunkList so return false which result in having the PoolChunk destroyed and
            // all memory associated with the PoolChunk will be released.
            assert chunk.usage() == 0;
            return false;
        }
        return prevList.move(chunk);
    }
1014396
def is_quota_exceeded(self) -> bool:
        ''''''

        if self.quota and self._url_table is not None:
            return self.size >= self.quota and \
                   self._url_table.get_root_url_todo_count() == 0
768224
def execute(self):
        
        self.bitshares.blocking = "head"
        r = self.bitshares.txbuffer.broadcast()
        self.bitshares.blocking = False
        return r