Closed vjh0107 closed 1 year ago
문제는 VirtualFactory 가 내부적으로 suspend 함수들로 처리된다는 점을 인지하고 사용하지 않아 발생하였습니다. virtual 스코프 내에서는 suspend 람다이기 때문에, 정상적으로 동시성이 보장됩니다. 수정한 후 동작하는 코드입니다.
override fun onOpen(vararg players: Player) {
val player = players.first()
val actualPlayerSlotStarts = this.inventory.size
player.virtual {
inventory {
repeat(36) { index ->
val actualPlayerSlot = actualPlayerSlotStarts + index
setItem(actualPlayerSlot, ItemStack(Material.BARRIER)) {
}
}
}
}
}
virtual factory 내를 suspend 임을 명시적으로 외부에 알릴 수 있는 방법이 있을까요?
virtual factory 내를 suspend 임을 명시적으로 외부에 알릴 수 있는 방법이 있을까요?
sequence
아래는 플레이어 인벤토리의 아이템을 전부 Barrier 로 변경하는 예제코드입니다. 아래 예제코드가 포함되어있는 HQContainer 을 open 할 시, 오류가 발생합니다. 오류의 발생은 간헐적으로, ConcurrentModificationException 과 IllegalCallableAccessException 이렇게 2 종류의 예외가 발생합니다.
예제 코드
IllegalCallableAccessException 의 경우는, 아래의 코드와 같이 출력해보았을 경우 예외가 던져지기 전 false 로 출력되어집니다. ConcurrentModificationException 과 같은 이유로 오류가 발생하는것으로 간주하고 해결해보도록 하겠습니다.
stacktrace 를 첨부합니다.
ConcurrentModificationException
IllegalCallableAccessException