embroidery.api

bounded-pmap*

(bounded-pmap* n f coll)

Version of pmap which uses JVM 21+ virtual threads when available, but will chunk the work up such that at most n concurrent virtual threads will be used (useful for workloads where system resource constraints could be exceeded e.g. maximum number of open file handles).

Notes:

  • degrades to vanilla pmap on JVMs that don’t support virtual threads
  • virtual thread version is partially lazy (results are computed eagerly, but merged lazily using concat)
  • non virtual thread version ignores the n argument (since pmap chunks coll itself, based on the number of CPUs)
  • each invocation of bounded-pmap* utilises an independent set of virtual threads, so parallel invocations may exceed system resource constraints

future*

macro

(future* & body)

Version of future which uses JVM 21+ virtual threads when available.

Notes:

  • degrades to vanilla future on JVMs that don’t support virtual threads

future-call*

(future-call* f)

Version of future-call that uses JVM 21+ virtual threads when available.

Notes:

  • degrades to vanilla future-call on JVMs that don’t support virtual threads

pmap*

(pmap* f coll)

Version of pmap which uses JVM 21+ virtual threads when available, one per item in coll.

Notes:

  • degrades to vanilla pmap on JVMs that don’t support virtual threads
  • virtual thread version is not lazy

virtual-threads-in-use?

Are virtual threads in use on this JVM?