| 43 | // TODO The next six methods are all in the recipe book: |
| 44 | // push, nextCount, pop (x2), and peek (x2). |
| 45 | public static void push(TransactionContext tcx, final Object value, final int priority){ |
| 46 | tcx.run(new Function<Transaction,Void>() { |
| 47 | public Void apply(Transaction tr){ |
| 48 | byte[] rands = new byte[20]; |
| 49 | randno.nextBytes(rands); |
| 50 | tr.set(pq.subspace(Tuple.from(priority, nextCount(tr,priority),rands)).pack(), |
| 51 | Tuple.from(value).pack()); |
| 52 | return null; |
| 53 | } |
| 54 | }); |
| 55 | } |
| 56 | |
| 57 | private static long nextCount(TransactionContext tcx, final int priority){ |
| 58 | return tcx.run(new Function<Transaction,Long>() { |