Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: runtime/vm/timeline.cc

Issue 1297443002: Improve timeline iterators and tests (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/timeline.h ('k') | runtime/vm/timeline_analysis.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <cstdlib> 5 #include <cstdlib>
6 6
7 #include "vm/isolate.h" 7 #include "vm/isolate.h"
8 #include "vm/json_stream.h" 8 #include "vm/json_stream.h"
9 #include "vm/lockers.h" 9 #include "vm/lockers.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 // Clear any extra data. 707 // Clear any extra data.
708 events_[i].Reset(); 708 events_[i].Reset();
709 } 709 }
710 length_ = 0; 710 length_ = 0;
711 } 711 }
712 712
713 713
714 TimelineEventBlockIterator::TimelineEventBlockIterator( 714 TimelineEventBlockIterator::TimelineEventBlockIterator(
715 TimelineEventRecorder* recorder) 715 TimelineEventRecorder* recorder)
716 : current_(NULL), 716 : current_(NULL),
717 recorder_(recorder) { 717 recorder_(NULL) {
718 if (recorder_ == NULL) { 718 Reset(recorder);
719 return;
720 }
721 recorder->lock_.Lock();
722 } 719 }
723 720
724 721
725 TimelineEventBlockIterator::~TimelineEventBlockIterator() { 722 TimelineEventBlockIterator::~TimelineEventBlockIterator() {
723 Reset(NULL);
724 }
725
726
727 void TimelineEventBlockIterator::Reset(TimelineEventRecorder* recorder) {
728 // Clear current.
729 current_ = NULL;
730 if (recorder_ != NULL) {
731 // Unlock old recorder.
732 recorder_->lock_.Unlock();
733 }
734 recorder_ = recorder;
726 if (recorder_ == NULL) { 735 if (recorder_ == NULL) {
727 return; 736 return;
728 } 737 }
729 recorder_->lock_.Unlock(); 738 // Lock new recorder.
739 recorder_->lock_.Lock();
740 // Queue up first block.
741 current_ = recorder_->GetHeadBlock();
730 } 742 }
731 743
732 744
733 void TimelineEventBlockIterator::Reset() { 745 bool TimelineEventBlockIterator::HasNext() const {
734 current_ = NULL; 746 return current_ != NULL;
735 } 747 }
736 748
737 749
738 bool TimelineEventBlockIterator::Next() { 750 TimelineEventBlock* TimelineEventBlockIterator::Next() {
739 if (recorder_ == NULL) { 751 ASSERT(current_ != NULL);
740 return false; 752 TimelineEventBlock* r = current_;
741 } 753 current_ = current_->next();
742 if (current_ == NULL) { 754 return r;
743 current_ = recorder_->GetHeadBlock();
744 } else {
745 current_ = current_->next();
746 }
747 return current_ != NULL;
748 } 755 }
749 756
750 } // namespace dart 757 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/timeline.h ('k') | runtime/vm/timeline_analysis.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698