>>> cache = Cache(log_level=logging.WARNING)
        >>> cache.unable_thread_pool()
        True
        >>> cache.unable_thread_pool()
        False
421993
def unable_thread_pool(self, only_read=False):
        
        if self.enable_thread_pool and hasattr(self, 'thread_pool') and self.thread_pool is not None:
            self.thread_pool.shutdown()
            self.thread_pool = None
            self.enable_thread_pool = False
            self.logger.debug('Remove thread pool completed')
            return True
        else:
            self.logger.warning('Current not have a thread pool is existent')
            return False
392811
def cache(self, con):
        """"""
        self._lock.acquire()
        try:
            if not self._maxcached or len(self._idle_cache) < self._maxcached:
                con._reset(force=self._reset)  # rollback possible transaction
                # the idle cache is not full, so put it there
                self._idle_cache.append(con)  # append it to the idle cache
            else:  # if the idle cache is already full,
                con.close()  # then close the connection
            self._connections -= 1
            self._lock.notify()
        finally:
            self._lock.release()
74678
public boolean isSharable() {
        /**
         * Cache the result of {@link Sharable} annotation detection to workaround a condition. We use a
         * {@link ThreadLocal} and {@link WeakHashMap} to eliminate the volatile write/reads. Using different
         * {@link WeakHashMap} instances per {@link Thread} is good enough for us and the number of
         * {@link Thread}s are quite limited anyway.
         *
         * See <a href="https://github.com/netty/netty/issues/2289">#2289</a>.
         */
        Class<?> clazz = getClass();
        Map<Class<?>, Boolean> cache = InternalThreadLocalMap.get().handlerSharableCache();
        Boolean sharable = cache.get(clazz);
        if (sharable == null) {
            sharable = clazz.isAnnotationPresent(Sharable.class);
            cache.put(clazz, sharable);
        }
        return sharable;
    }
28063
private static boolean canBulkLoad(AsyncCacheLoader<?, ?> loader) {
    try {
      Class<?> defaultLoaderClass = AsyncCacheLoader.class;
      if (loader instanceof CacheLoader<?, ?>) {
        defaultLoaderClass = CacheLoader.class;

        Method classLoadAll = loader.getClass().getMethod("loadAll", Iterable.class);
        Method defaultLoadAll = CacheLoader.class.getMethod("loadAll", Iterable.class);
        if (!classLoadAll.equals(defaultLoadAll)) {
          return true;
        }
      }

      Method classAsyncLoadAll = loader.getClass().getMethod(
          "asyncLoadAll", Iterable.class, Executor.class);
      Method defaultAsyncLoadAll = defaultLoaderClass.getMethod(
          "asyncLoadAll", Iterable.class, Executor.class);
      return !classAsyncLoadAll.equals(defaultAsyncLoadAll);
    } catch (NoSuchMethodException | SecurityException e) {
      logger.log(Level.WARNING, "Cannot determine if CacheLoader can bulk load", e);
      return false;
    }
  }
536141
public static AdvancedCache failSilentReadCache(AdvancedCache cache) {
		return cache.withFlags(
				Flag.FAIL_SILENTLY,
				Flag.ZERO_LOCK_ACQUISITION_TIMEOUT
		);
	}
383170
public static ThreadPoolExecutor newCachedThreadPool(int corePoolSize,
                                                         int maximumPoolSize,
                                                         BlockingQueue<Runnable> queue) {
        return new ThreadPoolExecutor(corePoolSize,
            maximumPoolSize,
            DateUtils.MILLISECONDS_PER_MINUTE,
            TimeUnit.MILLISECONDS,
            queue);
    }
68699
public void setCacheable(String cacheable) {

        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(cacheable)) {
            m_cacheable = Boolean.valueOf(cacheable).booleanValue();
        }
    }
707742
def with_thread_pool(self, init_func=None, only_read=False):
        
        if not hasattr(self, 'thread_pool') or self.thread_pool is None:
            if init_func is not None:
                self.thread_pool = init_func()
            else:
                self.thread_pool = _init_thread_pool()
            self.enable_thread_pool = True
            self.logger.debug('Initialize thread pool completed %s' % self.thread_pool)
            return True
        else:
            self.logger.warning('Already have a thread pool instance - %s' % self.thread_pool)
            return False
98516
private synchronized void createReconstituteThreadPool()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "createReconstituteThreadPool");

        if (_reconstituteThreadpool == null)
        {
            int maxThreadPoolSize;

            if (messageProcessor.getMessagingEngine().datastoreExists()) {
                //data store. Proceed and calcualte number of threads to use for reconstitution

                //get the thread pool size from the custom property
                maxThreadPoolSize = messageProcessor.getCustomProperties().get_max_reconstitute_threadpool_size();

                int noOfCores = CpuInfo.getAvailableProcessors();

                if (maxThreadPoolSize <= 0)
                {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                        SibTr.info(tc, "INVALID_RECONSTITUTE_THREADPOOL_SIZE_CWSIP0068", new Object[] { maxThreadPoolSize });
                    maxThreadPoolSize = noOfCores;
                }

                if (maxThreadPoolSize > noOfCores)
                    SibTr.warning(tc, "INVALID_RECONSTITUTE_THREADPOOL_SIZE_CWSIP0069");

            }
            else {
                // File store: Don't use multiple threads as it may lead to contention
                maxThreadPoolSize = 1;
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.info(tc, "MAX_RECONSTITUTE_THREADPOOL_SIZE_CWSIP0070", new Object[] { maxThreadPoolSize });

            _reconstituteThreadpool = new ThreadPoolExecutor(maxThreadPoolSize, maxThreadPoolSize, Long.MAX_VALUE, TimeUnit.MILLISECONDS,
                            new LinkedBlockingQueue<Runnable>());
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "createReconstituteThreadPool");
    }
1065847
def cache_result(cache_key, timeout):
    """"""
    def decorator(f):
        cache_name = settings.WAFER_CACHE

        @functools.wraps(f)
        def wrapper(*args, **kw):
            cache = caches[cache_name]
            result = cache.get(cache_key)
            if result is None:
                result = f(*args, **kw)
                cache.set(cache_key, result, timeout)
            return result

        def invalidate():
            cache = caches[cache_name]
            cache.delete(cache_key)

        wrapper.invalidate = invalidate
        return wrapper
    return decorator
28102
private LocalThreadObjectPool getThreadLocalObjectPool() {
        if (threadPoolSize <= 0) {
            // no local thread pool needed.
            return null;
        }
        LocalThreadObjectPool localPool = null;
        if (threadLocals != null) {
            localPool = threadLocals.get();
            if (localPool == null) {
                localPool = new LocalThreadObjectPool(threadPoolSize, null, destroyer); // @PK36998C
                threadLocals.set(localPool);

                localPool.setCleanUpOld(cleanUpOld);
            }
        }

        return localPool;
    }
1184413
def shutdown_thread_pool(self, only_read=False):
        
        if self.enable_thread_pool and hasattr(self, 'thread_pool') and self.thread_pool is not None:
            self.thread_pool.shutdown()
            return True
        else:
            self.logger.warning('Current not have a thread pool is existent')
            return False
850191
def can_use_cache(self, target: Target) -> bool:
        
        # if caching is disabled for this execution, then all targets are dirty
        if self.conf.no_build_cache:
            return False
        # if the target's `cachable` prop is falsy, then it is dirty
        if not target.props.cachable:
            return False
        # if any dependency of the target is dirty, then the target is dirty
        if any(self.targets[dep].is_dirty for dep in target.deps):
            return False
        # if the target has a dirty buildenv then it's also dirty
        if target.buildenv and self.targets[target.buildenv].is_dirty:
            return False
        return True
867471
def can_be_executed_by(self, thread_id):
        '''
        '''
        return self.thread_id == thread_id or self.thread_id.endswith('|' + thread_id)
257218
def check_cache(cache):
    
    if isinstance(cache, BaseCache):
        return cache
    elif cache is False:
        return DictCache()
    elif cache is None:
        return DummyCache()
    else:
        raise ValueError('Provided cache must implement BaseCache')
497302
public boolean isLowOnThreads()
   {
      if (executor instanceof ThreadPoolExecutor)
      {
         final ThreadPoolExecutor tpe = (ThreadPoolExecutor)executor;
         return tpe.getActiveCount() >= tpe.getMaximumPoolSize();
      }
      return false;
   }
868051
static <K, V> SerializationProxy<K, V> makeSerializationProxy(
      BoundedLocalCache<?, ?> cache, boolean isWeighted) {
    SerializationProxy<K, V> proxy = new SerializationProxy<>();
    proxy.weakKeys = cache.collectKeys();
    proxy.weakValues = cache.nodeFactory.weakValues();
    proxy.softValues = cache.nodeFactory.softValues();
    proxy.isRecordingStats = cache.isRecordingStats();
    proxy.removalListener = cache.removalListener();
    proxy.ticker = cache.expirationTicker();
    proxy.writer = cache.writer;
    if (cache.expiresAfterAccess()) {
      proxy.expiresAfterAccessNanos = cache.expiresAfterAccessNanos();
    }
    if (cache.expiresAfterWrite()) {
      proxy.expiresAfterWriteNanos = cache.expiresAfterWriteNanos();
    }
    if (cache.expiresVariable()) {
      proxy.expiry = cache.expiry();
    }
    if (cache.evicts()) {
      if (isWeighted) {
        proxy.weigher = cache.weigher;
        proxy.maximumWeight = cache.maximum();
      } else {
        proxy.maximumSize = cache.maximum();
      }
    }
    return proxy;
  }