149150151152153154155156157158159
{ throw new RuntimeException("orly?"); } try { sync.lockPage(page1); sync.lockPage(page2); // have locks, increment the count counts[page1].incrementAndGet(); counts[page2].incrementAndGet();
150151152153154155156157158159160
throw new RuntimeException("orly?"); } try { sync.lockPage(page1); sync.lockPage(page2); // have locks, increment the count counts[page1].incrementAndGet(); counts[page2].incrementAndGet(); hits.incrementAndGet();
4950515253545556575859
@Test public void testReentrant() throws Exception { final PageAccessSynchronizer sync = new PageAccessSynchronizer(Duration.seconds(5)); final Duration hold = Duration.seconds(1); sync.lockPage(0); sync.lockPage(0); } /** * @throws Exception
5051525354555657585960
public void testReentrant() throws Exception { final PageAccessSynchronizer sync = new PageAccessSynchronizer(Duration.seconds(5)); final Duration hold = Duration.seconds(1); sync.lockPage(0); sync.lockPage(0); } /** * @throws Exception */
6970717273747576777879
class T1 extends Thread { @Override public void run() { sync.lockPage(1); t1locks[0] = Time.now(); hold.sleep(); sync.unlockAllPages(); } }
8182838485868788899091
class T2 extends Thread { @Override public void run() { sync.lockPage(1); t2locks[0] = Time.now(); sync.unlockAllPages(); } }
148149150151152153154155156157158
4344454647484950515253
@Test public void testReentrant() throws Exception { final PageAccessSynchronizer sync = new PageAccessSynchronizer(Duration.seconds(5)); final Duration hold = Duration.seconds(1); sync.lockPage(0); sync.lockPage(0); } @Test public void testBlocking() throws Exception
4445464748495051525354
public void testReentrant() throws Exception { final PageAccessSynchronizer sync = new PageAccessSynchronizer(Duration.seconds(5)); final Duration hold = Duration.seconds(1); sync.lockPage(0); sync.lockPage(0); } @Test public void testBlocking() throws Exception {