groostav
03/08/2025, 1:02 AMUserProcessMutextryLock(): Booleanrelease()tryLockfun tryLock(): Boolean {
  val path = Path.of("/my-prog-mutex.lock")
  
  val fileChannel = FileChannel.open(path, StandardOpenOption.WRITE)
  lock = fileChannel.tryLock()
  if(lock == null) fileChannel.close()
  return lock != null
}suspend fun main(){
  
  val mutex = UserProcessMutex()
  mutex.tryLock()
  enterYieldingMainEventLoop()
  doFinallyTasks()
}mainrelease()mutexFileChannelmutexCLOVIS
03/09/2025, 12:59 PM