Request Concurrent dictionary

Discussion in 'Feature Suggestions' started by Troll Knight, Nov 7, 2016.

  1. Troll Knight

    Troll Knight Naked Wanderer

    Wulf,

    Does the oxide platform provide a concurrent dictionary? If not, is that on the roadmap?
     
  2. Troll Knight

    Troll Knight Naked Wanderer

    Wulf, any comment on this request?
     
  3. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Not really my area, so I can't really comment on it sorry.
     
  4. Troll Knight

    Troll Knight Naked Wanderer

    Thanks for the reply Wulf. Any idea who the owner for this would be?
     
  5. sqroot

    sqroot Plugin Developer

    What do you need a concurrent dictionary for?
     
  6. Troll Knight

    Troll Knight Naked Wanderer

    I have developed a plug-in that prohibits offline raiding in ROK. A feature of the offline raid protection is to also prevent logging out during combat to avoid damage to blocks or crests. To punish those that combat log, there is the concept of a cooldown period. A guild is added to the cooldown list when any block in their crested area has been damaged and they combat log. The cooldown period allows them to continue to be attacked for a specific period of time when they combat log. I implement this in my code when the CubeDamageEvent is raised. When this event is raised I add the guild to a dictionary where the key is a ulong from the guild socialId and the value is a datetime when the cooldown expires. The challenge is that during a very busy battle the CubeDamageEvent can be raised a lot of times simultaneously, causing exceptions when another event is trying to update datetime value for an item in the dictionary.

    I need the concurrent dictionary so I can implement a threadsafe dictionary to avoid the exceptions that arise from many CubeDamageEvents all trying to update a dictionary item at the same time. Without the concurrent dictionary the lag caused from the exceptions is huge. I have minimized the impact for now by seeking to structure the cooldown adds to occur when the first CubeDamageEvent happens for a guilds crested area. This means that the performance hit happens initially at the beginning of the battle because all subsequent dictionary actions are reads it minimizes the lag. However, this isn't really the way I wanted to implement the feature. I want to update the cooldown datetime every time a guild is successfully attacked online so that they face a full cooldown period when they combat log.