Created
February 9, 2018 22:07
-
-
Save bandrzejczak/ad75ffb9980b37a35d066f2fcc31a156 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static class UnsafeTrade { | |
private static long offset = 0; | |
private static final long ticketOffset = offset += 0; | |
private static final long amountOffset = offset += 4; | |
private static final long priceOffset = offset += 4; | |
private static final long buyOffset = offset += 4; | |
private static final long objectSize = offset += 1; | |
private long objectOffset; | |
public static long getObjectSize() { | |
return objectSize; | |
} | |
void setObjectOffset(final long objectOffset) { | |
this.objectOffset = objectOffset; | |
} | |
public void setTicket(final int ticket) { | |
unsafe.putInt(objectOffset + ticketOffset, ticket); | |
} | |
public long getPrice() { | |
return unsafe.getInt(objectOffset + priceOffset); | |
} | |
public void setPrice(final int price) { | |
unsafe.putInt(objectOffset + priceOffset, price); | |
} | |
//other getters and setters | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment