Process.kt

  1. package com.hexagontk.core

  2. import java.lang.management.ManagementFactory.getRuntimeMXBean
  3. import java.lang.management.RuntimeMXBean

  4. /**
  5.  * Object with utilities to gather information about the running process.
  6.  */
  7. object Process {
  8.     private val runtimeBean: RuntimeMXBean by lazy { getRuntimeMXBean() }

  9.     /** OS Process ID. */
  10.     val pid: Long by lazy { runtimeBean.pid }

  11.     /**
  12.      * Milliseconds since the process was created.
  13.      *
  14.      * @return Milliseconds since the process was created.
  15.      */
  16.     fun uptime(): Long =
  17.         runtimeBean.uptime
  18. }