<commit_before>package lila.mod

import lila.user.{ User, UserRepo }
import lila.security.Granter

object Impersonate {

  private var modToUser = Map.empty[User.ID, User.ID]
  private var userToMod = Map.empty[User.ID, User.ID]

  def start(mod: User, user: User) = Granter(_.Impersonate)(mod) ?? {
    modToUser = modToUser + (mod.id -> user.id)
    userToMod = userToMod + (user.id -> mod.id)
    logger.info(s"${mod.username} starts impersonating ${user.username}")
  }

  def stop(user: User) = userToMod.get(user.id) ?? { modId =>
    modToUser = modToUser - modId<commit_msg>fix concurrent impersonate<commit_after>package lila.mod

import lila.user.{ User, UserRepo }
import lila.security.Granter

object Impersonate {

  private var modToUser = Map.empty[User.ID, User.ID]
  private var userToMod = Map.empty[User.ID, User.ID]

  def start(mod: User, user: User): Unit = Granter(_.Impersonate)(mod) ?? {
    stop(user)
    modToUser = modToUser + (mod.id -> user.id)
    userToMod = userToMod + (user.id -> mod.id)
    logger.info(s"${mod.username} starts impersonating ${user.username}")
  }

  def stop(user: User): Unit = userToMod.get(user.id) ?? { modId =>
    modToUser = modToUser - modId
{'fraction_non_alphanumeric': 0.14451827242524917, 'fraction_numerical': 0.0, 'mean_word_length': 3.82, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2750217', 'n_tokens_mistral': 438, 'n_tokens_neox': 436, 'n_words': 96}