"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.prettyFiberId =
  exports.newFiberId =
  exports.equalsFiberID =
  exports.None =
  exports.FiberID =
    void 0
// tracing: off
const AtomicNumber_1 = require("../Support/AtomicNumber")
/**
 * Constructs a Fiber ID
 */
function FiberID(startTimeMillis, seqNumber) {
  return {
    _tag: "FiberID",
    seqNumber,
    startTimeMillis
  }
}
exports.FiberID = FiberID
/**
 * A sentinel value to indicate a fiber without identity.
 */
exports.None = FiberID(0, 0)
/**
 * Checks equality of Fiber IDs
 */
function equalsFiberID(x, y) {
  return x.seqNumber === y.seqNumber && x.startTimeMillis === y.startTimeMillis
}
exports.equalsFiberID = equalsFiberID
const _fiberCounter = new AtomicNumber_1.AtomicNumber(0)
/**
 * Constructs a new Fiber ID using current time and global increment
 */
function newFiberId() {
  return FiberID(new Date().getTime(), _fiberCounter.getAndIncrement())
}
exports.newFiberId = newFiberId
/**
 * Format a fiber id
 */
function prettyFiberId(_) {
  return `#${_.seqNumber} (started at: ${new Date(_.startTimeMillis).toISOString()})`
}
exports.prettyFiberId = prettyFiberId
//# sourceMappingURL=id.js.map
