NathanWolf / BukkitPlugins

My plugins for the Bukkit Minecraft server
mine.elmakers.com
14 stars 7 forks source link

Allowing concurrent read access #27

Open NathanWolf opened 13 years ago

NathanWolf commented 13 years ago

Persistence needs to use a read lock and a write lock to make access thread safe.

Any number of threads may read at one time (do I need to switch to concurrent hashmaps for this to be safe? I don't think so...), but only one thread may write at a time, and no thread may read while another is writing.

Over-simplified, but I think that should cover it.

NathanWolf commented 13 years ago

Hm, this needs more thought, but I'm downgrading it's "bug" status.

Persistence is, and has been, thread safe- I just want to optimize it somehow to allow concurrent reading.

NathanWolf commented 13 years ago

Hm- this still bears investigation. I don't think I'm using the read/write lock objects correctly, possibly at all- I think I'm just super locking everybody out of everything if anyone's doing anything, basically.

Not really performant, but I guess it's the safest thing for now, til I have time to get this truly sorted.

I think all I need is a write lock flag that I manage myself, and then an actual synchronized write lock- but I'm really going to need to dig into this, look at the code, make sure- see if I need to be using ConcurrentHashMaps anywhere I need to, etc.

It's a pretty big deal, so I'm going to just keep things safe for now and demote this issue.