|
19 | 19 | import java.util.ArrayList; |
20 | 20 | import java.util.List; |
21 | 21 | import java.util.Locale; |
| 22 | +import java.util.concurrent.atomic.AtomicInteger; |
22 | 23 |
|
23 | 24 |
|
24 | 25 | /** |
@@ -492,6 +493,7 @@ public static class LogToken implements ILogToken { |
492 | 493 | private volatile LogTokenState mState; |
493 | 494 | private long mLastSplitTimeCaptured = 0L; |
494 | 495 | private List<Split> mSplitRecord; |
| 496 | + private final AtomicInteger mSequenceNumber = new AtomicInteger(1); |
495 | 497 |
|
496 | 498 | // To be called only through LogTokenPool. Should not be created through any other ways. |
497 | 499 | protected LogToken() { |
@@ -561,6 +563,8 @@ public void reset() { |
561 | 563 | if (this.mSplitRecord != null) { |
562 | 564 | this.mSplitRecord.clear(); |
563 | 565 | } |
| 566 | + this.mSequenceNumber.set(1); |
| 567 | + this.mLastSplitTimeCaptured = 0L; |
564 | 568 | this.mSplitRecord = null; |
565 | 569 | } |
566 | 570 |
|
@@ -614,11 +618,11 @@ private Split createSplit() { |
614 | 618 | if (mLastSplitTimeCaptured == 0L) { // Split called for the first time |
615 | 619 | // We use the token start time as the reference. |
616 | 620 | mLastSplitTimeCaptured = ToolBox.currentTime(); |
617 | | - newSplit = new Split(getStart(), mLastSplitTimeCaptured); |
| 621 | + newSplit = new Split(getStart(), mLastSplitTimeCaptured, mSequenceNumber.getAndIncrement()); |
618 | 622 | } else { |
619 | 623 | // Here we use the last split time captured. |
620 | 624 | long currentTime = ToolBox.currentTime(); |
621 | | - newSplit = new Split(mLastSplitTimeCaptured, currentTime); |
| 625 | + newSplit = new Split(getStart(), mLastSplitTimeCaptured, mSequenceNumber.getAndIncrement()); |
622 | 626 | mLastSplitTimeCaptured = currentTime; |
623 | 627 | } |
624 | 628 | } |
|
0 commit comments