Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

Latest commit

 

History

History
83 lines (72 loc) · 2.59 KB

notes.md

File metadata and controls

83 lines (72 loc) · 2.59 KB

Interanl/Runtime redesign notes.

Usages of internal/runtime services.

  • Ref registration/lookup
    • Unpickle
      • _root_.scala.pickling.internal.package.preregisterUnpicklee()
      • _root_.scala.pickling.internal.package.registerUnpicklee($instance, oid)
    • Pickle
      • _root_.scala.pickling.internal.package.lookupPicklee(picklee)
  • Current Runtime Mirror
    • FastTypeTag
      • _root_.scala.pickling.internal.package.currentMirror
    • Dynamic Unpicklers
      • _root_.scala.pickling.internal.package.currentMirror
  • Runtime Pickler Generation
    • Unpickle
      • _root_.scala.pickling.runtime.RuntimeUnpicklerLookup.genUnpickler(_root_.scala.pickling.internal.package.currentMirror, tagKey)
    • Pickle
      • _root_.scala.pickling.runtime.RuntimePicklerLookup.genPickler
  • Global Refelection Lock
    • Pickel
      • _root_.scala.pickling.internal.GRL.lock()
  • CAVEAT - The Ref unpickler should probably actually just be a direct runtime call, rather than what happens now.

Proposal

// Note: The RefRegistry should actually be a TLS, and handle a specific pickle/unpickle call.
trait RefRegistry {
  // Pickling
  def registerPicklee(picklee: Any): Int
  // Unpickling
  def preregisterUnpicklee(): Int
  def regsiterUnpicklee(oid: Int, value: Any): Unit
  def lookupUnpicklee(oid: Int): Option[Any]
  // Removes all instances from the registry.  This should be done AFTER a top-level unpickle/pickle call.
  def clear(): Unit
}
// User-Facing API (for making picklers)
// Each of these methods NEEDS to be 100% thread-safe.
trait PicklerRegistry {
  def lookupUnpickler[T]: Unpickler[T]
  def lookupPickler[T]: Pickler[T]
  def registerPickler[T](p: Pickler[T]): Unit
  def registerUnpickler[T](p: Unpickler[T]): Unit
  // TODO - Some kind of clean or inspect what we have?
}