From: Brian H. <bri...@ac...> - 2004-02-06 05:23:36
Attachments:
ReadWriteLock.java
|
Boy did I open a can of worms. My ReadWriteLock class was lacking in two = areas. It does not allow for nested read locks or a read lock inside of a = write lock. =20 So I created a test suite to hammer my read write lock. I added the above = two features and then ran it along side the read write lock from jedit. = This is where I found a bug in the jedit version. It allowed a read lock = to occur when a write lock was already in place. Being very proud of what I had done I put my class in the jedit code and = compiled. It worked great until I hit the undo button in jedit and the = whole thing locked up. Looks like that bug is a feature ;) It seems to me that allowing for nested locks is not a good design and = tends to complicate the code. What does everyone else think? Also are there any unit tests written for the jEdit source? Would anyone = object if I started adding them to the build? Any way for anyone who cares to see what I've come up with I've attached = my ReadWriteLock class Brian |
From: Brad M. <bm...@bl...> - 2004-02-06 16:34:55
|
jEdit currently has *no* unit testing. Slava has mentioned that he "should probably do some of that". Visit IRC #jedit and figure something out with him. Brad Brian Hawkins wrote: >Boy did I open a can of worms. My ReadWriteLock class was lacking in two areas. It does not allow for nested read locks or a read lock inside of a write lock. > >So I created a test suite to hammer my read write lock. I added the above two features and then ran it along side the read write lock from jedit. This is where I found a bug in the jedit version. It allowed a read lock to occur when a write lock was already in place. > >Being very proud of what I had done I put my class in the jedit code and compiled. It worked great until I hit the undo button in jedit and the whole thing locked up. Looks like that bug is a feature ;) > >It seems to me that allowing for nested locks is not a good design and tends to complicate the code. What does everyone else think? > >Also are there any unit tests written for the jEdit source? Would anyone object if I started adding them to the build? > >Any way for anyone who cares to see what I've come up with I've attached my ReadWriteLock class > >Brian > > |
From: Slava P. <sl...@je...> - 2004-02-10 07:06:07
|
Hey, The lock tries to be re-entrant when called from the same thread in some cases. The following is ok: read lock read lock read unlock read unlock write lock read lock read unlock write unlock The following is not ok: read lock write lock write unlock read unlock The following probably will lock it up too: write lock write lock write unlock write unlock Keeping these semantics is vital, since a lot of code depends on them. On Fri, 2004-02-06 at 00:23, Brian Hawkins wrote: > Boy did I open a can of worms. My ReadWriteLock class was lacking in two areas. It does not allow for nested read locks or a read lock inside of a write lock. > > So I created a test suite to hammer my read write lock. I added the above two features and then ran it along side the read write lock from jedit. This is where I found a bug in the jedit version. It allowed a read lock to occur when a write lock was already in place. > > Being very proud of what I had done I put my class in the jedit code and compiled. It worked great until I hit the undo button in jedit and the whole thing locked up. Looks like that bug is a feature ;) > > It seems to me that allowing for nested locks is not a good design and tends to complicate the code. What does everyone else think? > > Also are there any unit tests written for the jEdit source? Would anyone object if I started adding them to the build? > > Any way for anyone who cares to see what I've come up with I've attached my ReadWriteLock class > > Brian -- Slava Pestov |