Skip to content

Instantly share code, notes, and snippets.

public void serialisePublishing(final long sequence,
final Sequence cursor,
final int batchSize) {
final long expectedSequence = sequence - batchSize;
while (expectedSequence != cursor.get()) {
// busy spin
}
cursor.set(sequence);
public long incrementAndGet(AtomicLong atomic) {
long expected;
long updated
do {
expected = atomic.get();
updated = expected + 1;
}
while (!atomic.compareAndSet(expected, updated));
return updated;
@mikeb01
mikeb01 / ExecutionTracking.java
Created December 22, 2011 15:33
Tracked Execution for an Order
public class ExecutionTracking implements OrderEventListener, ExecutionEventListener
{
private final Session tradingSession;
final Map<Long, Order> lastOrderStateByInstructionId = new HashMap<Long, Order>();
Order currentOrder = null;
long currentFilledQuantity;
long currentCancelledQuantity;
public ExecutionTracking(final Session tradingSession)
{
@mikeb01
mikeb01 / gist:1510494
Created December 22, 2011 14:34
Order Protocol Event
<order>
<timeInForce>ImmediateOrCancel</timeInForce>
<instructionId>1733844027851145216</instructionId>
<originalInstructionId>1733844027851145216</originalInstructionId>
<orderId>AAK8oAAAAAAAAAAF</orderId>
<accountId>1393236922</accountId>
<instrumentId>179361</instrumentId>
<quantity>30</quantity>
<matchedQuantity>30</matchedQuantity>
<matchedCost>22.1</matchedCost>