| 62 | |
| 63 | // Add an element to the queue. |
| 64 | public static void enqueue(TransactionContext tcx, final Object value){ |
| 65 | tcx.run(new Function<Transaction,Void>() { |
| 66 | public Void apply(Transaction tr){ |
| 67 | byte[] rands = new byte[20]; |
| 68 | randno.nextBytes(rands); // Create random seed to avoid conflicts. |
| 69 | tr.set(queue.subspace(Tuple.from(lastIndex(tr)+1, rands)).pack(), |
| 70 | Tuple.from(value).pack()); |
| 71 | |
| 72 | return null; |
| 73 | } |
| 74 | }); |
| 75 | } |
| 76 | |
| 77 | // Get the top element of the queue. |
| 78 | private static KeyValue firstItem(TransactionContext tcx){ |