Commit 530e36d7 authored by ulan's avatar ulan Committed by Commit bot

Correctly handle the case when TimerTask is destroyed with being run.

This is follow-up for a5616e.

BUG=chromium:508584
LOG=NO

Review URL: https://codereview.chromium.org/1234513003

Cr-Commit-Position: refs/heads/master@{#29594}
parent a1475dae
......@@ -177,6 +177,13 @@ void MemoryReducer::ScheduleTimer(double delay_ms) {
}
void MemoryReducer::ClearTask(v8::Task* task) {
if (pending_task_ == task) {
pending_task_ = nullptr;
}
}
void MemoryReducer::TearDown() {
if (pending_task_ != nullptr) {
pending_task_->NotifyHeapTearDown();
......
......@@ -114,7 +114,7 @@ class MemoryReducer {
// Posts a timer task that will call NotifyTimer after the given delay.
void ScheduleTimer(double delay_ms);
void TearDown();
void ClearTask(v8::Task* task);
static const int kLongDelayMs;
static const int kShortDelayMs;
static const int kMaxNumberOfGCs;
......@@ -126,7 +126,11 @@ class MemoryReducer {
public:
explicit TimerTask(MemoryReducer* memory_reducer)
: memory_reducer_(memory_reducer), heap_is_torn_down_(false) {}
virtual ~TimerTask() {}
virtual ~TimerTask() {
if (!heap_is_torn_down_) {
memory_reducer_->ClearTask(this);
}
}
void NotifyHeapTearDown() { heap_is_torn_down_ = true; }
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment