| 436 | } |
| 437 | |
| 438 | void doEnsure(Ref ref){ |
| 439 | if(!info.running()) |
| 440 | throw retryex; |
| 441 | if(ensures.contains(ref)) |
| 442 | return; |
| 443 | ref.lock.readLock().lock(); |
| 444 | |
| 445 | //someone completed a write after our snapshot |
| 446 | if(ref.tvals != null && ref.tvals.point > readPoint) { |
| 447 | ref.lock.readLock().unlock(); |
| 448 | throw retryex; |
| 449 | } |
| 450 | |
| 451 | Info refinfo = ref.tinfo; |
| 452 | |
| 453 | //writer exists |
| 454 | if(refinfo != null && refinfo.running()) |
| 455 | { |
| 456 | ref.lock.readLock().unlock(); |
| 457 | |
| 458 | if(refinfo != info) //not us, ensure is doomed |
| 459 | { |
| 460 | blockAndBail(refinfo); |
| 461 | } |
| 462 | } |
| 463 | else |
| 464 | ensures.add(ref); |
| 465 | } |
| 466 | |
| 467 | Object doCommute(Ref ref, IFn fn, ISeq args) { |
| 468 | if(!info.running()) |