Closed Bethibande closed 8 months ago
BehaviorMap is now synchronized using a ReentrantReadWrite lock, not ideal but should be fine as read operations can still occur concurrently and write operations to the underlying HashMap should be very fast thus only locking actor coroutines for a very short time.
BehaviorMap is currently not thread-safe, if a BehaviorMap is modifier whilst actors already use it, the map could break or even throw exception. The behavior in such a situation is unknown. Making the class thread-safe could be challenging due to the fact that read operations occur in a coroutine context but write operations don't, also the get method used to read the map is not suspending (could be though). Simply synchronizing the map with a ReentrantReadWriteLock is not a good idea since that could lead to coroutine worker threads getting locked.