From 8400311e9c058b5df7dd2adeabdecea5f3c31576 Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Wed, 20 May 2015 16:39:55 +0100 Subject: [PATCH] Fix support for Throwable/Exceptions in Wire. --- .../map/fromdocs/BondVOInterface$$Native.java | 80 +++++++++---------- .../map/fromdocs/BondVOInterface.java | 7 -- .../pingpong_latency/PingPongLockLeft.java | 5 +- 3 files changed, 41 insertions(+), 51 deletions(-) mode change 100644 => 100755 src/test/java/net/openhft/chronicle/map/fromdocs/BondVOInterface$$Native.java mode change 100644 => 100755 src/test/java/net/openhft/chronicle/map/fromdocs/BondVOInterface.java mode change 100644 => 100755 src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongLockLeft.java diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/BondVOInterface$$Native.java b/src/test/java/net/openhft/chronicle/map/fromdocs/BondVOInterface$$Native.java old mode 100644 new mode 100755 index 6ab936a20..e2ef85b36 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/BondVOInterface$$Native.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/BondVOInterface$$Native.java @@ -31,61 +31,54 @@ public class BondVOInterface$$Native private static final int COUPON = 0; private static final int ISSUEDATE = 8; private static final int MATURITYDATE = 16; - private static final int ENTRY = 24; - private static final int MARKETPXINTRADAYHISTORY = 28; + private static final int MARKETPXINTRADAYHISTORY = 24; + private static final int SYMBOL = 304; private final BondVOInterface$MarketPx$$Native _marketPxIntraDayHistory[] = new BondVOInterface$MarketPx$$Native[7]; { for (int i = 0; i < 7; i++) _marketPxIntraDayHistory[i] = new BondVOInterface$MarketPx$$Native(); } - private static final int SYMBOL = 308; - - private Bytes _bytes; private long _offset; - - - public void setCoupon(double $) { - _bytes.writeDouble(_offset + COUPON, $); - } - public double getCoupon() { return _bytes.readDouble(_offset + COUPON); } - public double addAtomicCoupon(double $) { - return _bytes.addAtomicDouble(_offset + COUPON, $); - } public boolean compareAndSwapCoupon(double _1, double _2) { - return _bytes.compareAndSwapDouble(_offset + COUPON, _1, _2); + public void setCoupon(double $) { + _bytes.writeDouble(_offset + COUPON, $); } - public void setIssueDate(long $) { - _bytes.writeLong(_offset + ISSUEDATE, $); + public double addAtomicCoupon(double $) { + return _bytes.addAtomicDouble(_offset + COUPON, $); + } + + public boolean compareAndSwapCoupon(double _1, double _2) { + return _bytes.compareAndSwapDouble(_offset + COUPON, _1, _2); } public long getIssueDate() { return _bytes.readLong(_offset + ISSUEDATE); } - - - public void setMaturityDate(long $) { - _bytes.writeLong(_offset + MATURITYDATE, $); + public void setIssueDate(long $) { + _bytes.writeLong(_offset + ISSUEDATE, $); } public long getMaturityDate() { return _bytes.readLong(_offset + MATURITYDATE); } + public void setMaturityDate(long $) { + _bytes.writeLong(_offset + MATURITYDATE, $); + } + public long addAtomicMaturityDate(long $) { return _bytes.addAtomicLong(_offset + MATURITYDATE, $); - } public void unlockEntry() { - _bytes.unlockInt(_offset + ENTRY); - } public void busyLockEntry() throws InterruptedException { - _bytes.busyLockInt(_offset + ENTRY); - } public void setMarketPxIntraDayHistoryAt(int i, BondVOInterface.MarketPx $) { + } + + public void setMarketPxIntraDayHistoryAt(int i, BondVOInterface.MarketPx $) { _marketPxIntraDayHistory[i].copyFrom($); } @@ -93,22 +86,20 @@ public class BondVOInterface$$Native return _marketPxIntraDayHistory[i]; } - + public java.lang.String getSymbol() { + return _bytes.readUTFΔ(_offset + SYMBOL); + } public void setSymbol(java.lang.String $) { _bytes.writeUTFΔ(_offset + SYMBOL, 20, $); } - public java.lang.String getSymbol() { - return _bytes.readUTFΔ(_offset + SYMBOL); - } - @Override public void copyFrom(BondVOInterface from) { setCoupon(from.getCoupon()); setIssueDate(from.getIssueDate()); setMaturityDate(from.getMaturityDate()); - for (int i = 0; i < 7; i++){ + for (int i = 0; i < 7; i++) { setMarketPxIntraDayHistoryAt(i, from.getMarketPxIntraDayHistoryAt(i)); } setSymbol(from.getSymbol()); @@ -119,41 +110,46 @@ public class BondVOInterface$$Native out.writeDouble(getCoupon()); out.writeLong(getIssueDate()); out.writeLong(getMaturityDate()); - for (int i = 0; i < 7; i++){ + for (int i = 0; i < 7; i++) { _marketPxIntraDayHistory[i].writeMarshallable(out); } out.writeUTFΔ(getSymbol()); } + @Override public void readMarshallable(Bytes in) { setCoupon(in.readDouble()); setIssueDate(in.readLong()); setMaturityDate(in.readLong()); - for (int i = 0; i < 7; i++){ + for (int i = 0; i < 7; i++) { _marketPxIntraDayHistory[i].readMarshallable(in); } setSymbol(in.readUTFΔ()); } + @Override public void bytes(Bytes bytes, long offset) { this._bytes = bytes; this._offset = offset; - for (int i = 0; i < 7; i++){ + for (int i = 0; i < 7; i++) { ((Byteable) _marketPxIntraDayHistory[i]).bytes(bytes, _offset + MARKETPXINTRADAYHISTORY + (i * 40)); } } + @Override public Bytes bytes() { return _bytes; } + @Override public long offset() { return _offset; } + @Override public int maxSize() { - return 328; + return 324; } public long longHashCode_marketPxIntraDayHistory() { @@ -182,14 +178,14 @@ public class BondVOInterface$$Native if (!(o instanceof BondVOInterface)) return false; BondVOInterface that = (BondVOInterface) o; - if(!isEqual(getCoupon(), that.getCoupon())) return false; - if(!isEqual(getIssueDate(), that.getIssueDate())) return false; - if(!isEqual(getMaturityDate(), that.getMaturityDate())) return false; - for (int i = 0; i <7; i++) { - if(!isEqual(getMarketPxIntraDayHistoryAt(i), that.getMarketPxIntraDayHistoryAt(i))) + if (!isEqual(getCoupon(), that.getCoupon())) return false; + if (!isEqual(getIssueDate(), that.getIssueDate())) return false; + if (!isEqual(getMaturityDate(), that.getMaturityDate())) return false; + for (int i = 0; i < 7; i++) { + if (!isEqual(getMarketPxIntraDayHistoryAt(i), that.getMarketPxIntraDayHistoryAt(i))) return false; } - if(!isEqual(getSymbol(), that.getSymbol())) return false; + if (!isEqual(getSymbol(), that.getSymbol())) return false; return true; } diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/BondVOInterface.java b/src/test/java/net/openhft/chronicle/map/fromdocs/BondVOInterface.java old mode 100644 new mode 100755 index ec567ce9c..ff93f138f --- a/src/test/java/net/openhft/chronicle/map/fromdocs/BondVOInterface.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/BondVOInterface.java @@ -21,13 +21,6 @@ package net.openhft.chronicle.map.fromdocs; import net.openhft.lang.model.constraints.MaxSize; public interface BondVOInterface { - /* add support for entry based locking */ - @Deprecated() - void busyLockEntry() throws InterruptedException; - - @Deprecated() - void unlockEntry(); - long getIssueDate(); void setIssueDate(long issueDate); /* time in millis */ diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongLockLeft.java b/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongLockLeft.java old mode 100644 new mode 100755 index 2fa0ae23a..47f2df45b --- a/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongLockLeft.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongLockLeft.java @@ -70,7 +70,8 @@ public class PingPongLockLeft { } private static void toggleCoupon(BondVOInterface bond, double _coupon, double _coupon2) throws InterruptedException { - for (int i = 0; ; i++) { + throw new UnsupportedOperationException(); + /* for (int i = 0; ; i++) { bond.busyLockEntry(); try { if (bond.getCoupon() == _coupon) { @@ -82,6 +83,6 @@ public class PingPongLockLeft { } finally { bond.unlockEntry(); } - } + }*/ } } \ No newline at end of file