PlatformSpecific

zio.blocks.streams.PlatformSpecific
trait PlatformSpecific extends Platform

JVM implementation of the cross-platform Platform capabilities.

Mixed into the package-level Platform object on JVM, so call sites use the same Platform.* surface regardless of platform.

  • supportsConcurrency is true.
  • startVirtualThread uses Thread.ofVirtual().start(...) reflectively when running on JDK 21+, falling back to a daemon Thread otherwise.
  • createBufferedReader, createMergeReader, and createMapParReader return primitive-specialized readers (Int / Long / Float / Double) when the upstream's JvmType allows it, and the generic AnyRef variants otherwise.

Attributes

Source
PlatformSpecific.scala
Graph
Supertypes
trait Platform
class Object
trait Matchable
class Any
Known subtypes
object Platform

Members list

Value members

Concrete methods

override def createBufferedReaderFromReader[A](upstream: Reader[A], bufferSize: Int): Reader[A]

Returns a Reader that buffers elements produced by upstream into a bounded buffer of size bufferSize. On JVM, the producer runs on a separate virtual thread (concurrent). On JS, the reader prefetches elements synchronously.

Returns a Reader that buffers elements produced by upstream into a bounded buffer of size bufferSize. On JVM, the producer runs on a separate virtual thread (concurrent). On JS, the reader prefetches elements synchronously.

Attributes

Definition Classes
Source
PlatformSpecific.scala
override def createMapParReaderFromReader[A, B](upstream: Reader[A], n: Int, f: A => B, bufferSize: Int, inType: JvmType, outType: JvmType): Reader[B]

Returns a Reader that applies f to each element of upstream using n concurrent workers. On JVM, workers run on virtual threads. On JS, degrades to sequential map.

Returns a Reader that applies f to each element of upstream using n concurrent workers. On JVM, workers run on virtual threads. On JS, degrades to sequential map.

Attributes

Definition Classes
Source
PlatformSpecific.scala
override def createMergeReaderFromReader[A](outerReader: Reader[_], maxOpen: Int, bufferSize: Int, elemType: JvmType): Reader[A]

Returns a Reader that merges elements from N inner streams produced by outerReader, up to maxOpen concurrent inner streams at a time. On JVM, producers run on virtual threads. On JS, degrades to sequential flatMap.

Returns a Reader that merges elements from N inner streams produced by outerReader, up to maxOpen concurrent inner streams at a time. On JVM, producers run on virtual threads. On JS, degrades to sequential flatMap.

Attributes

Definition Classes
Source
PlatformSpecific.scala
override def startVirtualThread(name: String, task: Runnable): Thread

Starts a new thread and runs task on it. Returns the started thread (which can be java.lang.Thread#joined). On JVM, uses a virtual thread (JDK 21+) if available, otherwise a raw daemon thread. On Scala.js, always throws UnsupportedOperationException.

Starts a new thread and runs task on it. Returns the started thread (which can be java.lang.Thread#joined). On JVM, uses a virtual thread (JDK 21+) if available, otherwise a raw daemon thread. On Scala.js, always throws UnsupportedOperationException.

Attributes

Definition Classes
Source
PlatformSpecific.scala

Inherited methods

final def createBufferedReader[A](upstream: SyncReader[A], bufferSize: Int): SyncReader[A]

Attributes

Inherited from:
Platform
Source
Platform.scala
final def createMapParReader[A, B](upstream: SyncReader[A], n: Int, f: A => B, bufferSize: Int, inType: JvmType, outType: JvmType): SyncReader[B]

Attributes

Inherited from:
Platform
Source
Platform.scala

Concrete fields

override val supportsConcurrency: Boolean

Whether this platform supports true concurrent threads. true on JVM, false on Scala.js.

Whether this platform supports true concurrent threads. true on JVM, false on Scala.js.

Attributes

Source
PlatformSpecific.scala