RefCountedClassLoaderCache

mill.util.RefCountedClassLoaderCache
class RefCountedClassLoaderCache(sharedLoader: ClassLoader = ..., sharedPrefixes: Seq[String] = ..., parent: ClassLoader = ...) extends CachedFactoryBase[Seq[PathRef], Long, Enclosing, URLClassLoader]

Caches classloaders that can be shared between different workers, keeping a reference count of each classloader and only closing it after no more references exist

Attributes

Source
RefCountedClassLoaderCache.scala
Graph
Supertypes
class CachedFactoryBase[Seq[PathRef], Long, Enclosing, URLClassLoader]
trait AutoCloseable
class Object
trait Matchable
class Any

Members list

Type members

Inherited types

type Entry = Entry[Seq[PathRef], Long, URLClassLoader]

Attributes

Inherited from:
CachedFactoryBase
Source
CachedFactoryBase.scala

Value members

Concrete methods

def extraRelease(cl: ClassLoader): Unit
def get(combinedCompilerJars: Seq[PathRef])(using e: Enclosing): URLClassLoader

Convenience method that uses implicit sourcecode.Enclosing

Convenience method that uses implicit sourcecode.Enclosing

Attributes

Source
RefCountedClassLoaderCache.scala
def keyToInternalKey(key: Seq[PathRef]): Long

Convert the public key to an internal key used for caching.

Convert the public key to an internal key used for caching.

Attributes

Source
RefCountedClassLoaderCache.scala
def maxCacheSize: Int

Maximum number of unused values to keep in the LRU cache. Set to 0 to disable caching of unused values (values are closed immediately when released).

Maximum number of unused values to keep in the LRU cache. Set to 0 to disable caching of unused values (values are closed immediately when released).

Attributes

Source
RefCountedClassLoaderCache.scala
override def release(key: Seq[PathRef]): Option[Entry]

Release a reference to the value associated with the given key. If this was the last reference, the value moves to the unused cache.

Release a reference to the value associated with the given key. If this was the last reference, the value moves to the unused cache.

Attributes

Returns

Some(entry) if there are still active references (only possible in shared mode), None otherwise

Definition Classes
Source
RefCountedClassLoaderCache.scala
def releaseClassLoader(combinedCompilerJars: Seq[PathRef]): Option[(URLClassLoader, Int)]

Binary compatibility shim - returns (URLClassLoader, Int) tuple instead of Entry

Binary compatibility shim - returns (URLClassLoader, Int) tuple instead of Entry

Attributes

Source
RefCountedClassLoaderCache.scala
def setup(key: Seq[PathRef], internalKey: Long, initData: Enclosing): URLClassLoader

Create a new value for the given key.

Create a new value for the given key.

Attributes

Source
RefCountedClassLoaderCache.scala
def shareValues: Boolean

If true, a value can be used concurrently by multiple consumers (reference counted). If false, a value can only be used by one consumer at a time.

If true, a value can be used concurrently by multiple consumers (reference counted). If false, a value can only be used by one consumer at a time.

Attributes

Source
RefCountedClassLoaderCache.scala
def teardown(key: Seq[PathRef], internalKey: Long, value: URLClassLoader): Unit

Clean up a value when it is evicted from the cache.

Clean up a value when it is evicted from the cache.

Attributes

Source
RefCountedClassLoaderCache.scala

Inherited methods

def cacheEntryStillValid(key: Seq[PathRef], internalKey: Long, initData: => Enclosing, value: URLClassLoader): Boolean

Returns true if the cache entry associated with the given key is still valid. If false, the entry will be removed from the cache and setup will be invoked.

Returns true if the cache entry associated with the given key is still valid. If false, the entry will be removed from the cache and setup will be invoked.

Attributes

Inherited from:
CachedFactoryBase
Source
CachedFactoryBase.scala
override def close(): Unit

Attributes

Definition Classes
CachedFactoryBase -> AutoCloseable
Inherited from:
CachedFactoryBase
Source
CachedFactoryBase.scala
def getOrCreate(key: Seq[PathRef], initData: => Enclosing): URLClassLoader

Get a value for the given key, creating one if necessary. The caller must call release when done with the value.

Get a value for the given key, creating one if necessary. The caller must call release when done with the value.

Attributes

Inherited from:
CachedFactoryBase
Source
CachedFactoryBase.scala
def releaseKeyValue(key: Seq[PathRef], value: URLClassLoader): Option[Entry]

Release a reference to a specific value, matching by value identity. This should be used when shareValues = false and multiple entries may have the same key.

Release a reference to a specific value, matching by value identity. This should be used when shareValues = false and multiple entries may have the same key.

Attributes

Inherited from:
CachedFactoryBase
Source
CachedFactoryBase.scala
def withValue[R](key: Seq[PathRef], initData: => Enclosing)(block: URLClassLoader => R): R

Get a value, use it in the provided block, then release it.

Get a value, use it in the provided block, then release it.

Attributes

Inherited from:
CachedFactoryBase
Source
CachedFactoryBase.scala