
Building #ElectricClojure and https://xitter.cf/t.co/JkYr6J4dpu. I believe in excellence, and I believe that many others do too. Baháʼí. https://xitter.cf/t.co/aBmRZmuoCs
- Tweets3.1K
- Following3.2K
- Followers4.6K
- Likes16.2K

ALT opaque type State = Long object State: // Bit allocation: // Bits 0-15 (16 bits): depth (0-65535) // Bit 16 (1 bit): hasInterceptor flag // Bits 17-63 (47 bits): threadId private inline def DepthMask: Long = 0xffffL private inline def InterceptorMask: Long = 1L << 16 private inline def ThreadIdMask: Long = 0xffffffffffff0000L require(maxStackDepth <= 65536) inline def init(): State = (Thread.currentThread().getId() << 17) & ThreadIdMask extension (state: State) def depth: Int = (state & DepthMask).toInt def threadId: Long = (state & ThreadIdMask) >>> 17 def hasInterceptor: Boolean = (state & InterceptorMask) != 0 def incrementDepth: State = state + 1 def decrementDepth: State = state - 1 def withInterceptor(hasInterceptor: Boolean): State = if hasInterceptor then state | InterceptorMask else state & ~InterceptorMask



















