Skip to content

Commit 15062ca

Browse files
author
George Wright
authored
Revert "Re-arm timer as necessary in MessageLoopFuchsia" (flutter#16568)
This reverts commit 8ec994b.
1 parent c4c6ef6 commit 15062ca

File tree

3 files changed

+4
-44
lines changed

3 files changed

+4
-44
lines changed

fml/message_loop_unittests.cc

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "flutter/fml/build_config.h"
1111
#include "flutter/fml/concurrent_message_loop.h"
1212
#include "flutter/fml/message_loop.h"
13-
#include "flutter/fml/message_loop_impl.h"
1413
#include "flutter/fml/synchronization/count_down_latch.h"
1514
#include "flutter/fml/synchronization/waitable_event.h"
1615
#include "flutter/fml/task_runner.h"
@@ -316,32 +315,3 @@ TEST(MessageLoop, CanCreateConcurrentMessageLoop) {
316315
latch.Wait();
317316
ASSERT_GE(thread_ids.size(), 1u);
318317
}
319-
320-
TEST(MessageLoop, TIME_SENSITIVE(WakeUpTimersAreSingletons)) {
321-
auto loop_impl = fml::MessageLoopImpl::Create();
322-
323-
const auto t1 = fml::TimeDelta::FromMilliseconds(10);
324-
const auto t2 = fml::TimeDelta::FromMilliseconds(20);
325-
326-
const auto begin = fml::TimePoint::Now();
327-
328-
// Register a task scheduled for 10ms in the future. This schedules a
329-
// WakeUp call on the MessageLoopImpl with that fml::TimePoint
330-
loop_impl->PostTask(
331-
[&]() {
332-
auto delta = fml::TimePoint::Now() - begin;
333-
auto ms = delta.ToMillisecondsF();
334-
ASSERT_GE(ms, 10);
335-
ASSERT_LE(ms, 25);
336-
337-
loop_impl->Terminate();
338-
},
339-
fml::TimePoint::Now() + t1);
340-
341-
// Call WakeUp manually to change the WakeUp time to the future. If the
342-
// timer is correctly set up to be rearmed instead of a new timer scheduled,
343-
// the above task will be executed at t2 instead of t1 now.
344-
loop_impl->WakeUp(fml::TimePoint::Now() + t2);
345-
346-
loop_impl->Run();
347-
}

fml/platform/fuchsia/message_loop_fuchsia.cc

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@
55
#include "flutter/fml/platform/fuchsia/message_loop_fuchsia.h"
66

77
#include <lib/async-loop/default.h>
8+
#include <lib/async/cpp/task.h>
89
#include <lib/zx/time.h>
910

1011
namespace fml {
1112

1213
MessageLoopFuchsia::MessageLoopFuchsia()
13-
: loop_(&kAsyncLoopConfigAttachToCurrentThread) {
14-
auto handler = [this](async_dispatcher_t* dispatcher, async::Task* task,
15-
zx_status_t status) { RunExpiredTasksNow(); };
16-
task_.set_handler(handler);
17-
}
14+
: loop_(&kAsyncLoopConfigAttachToCurrentThread) {}
1815

1916
MessageLoopFuchsia::~MessageLoopFuchsia() = default;
2017

@@ -33,12 +30,8 @@ void MessageLoopFuchsia::WakeUp(fml::TimePoint time_point) {
3330
due_time = zx::nsec((time_point - now).ToNanoseconds());
3431
}
3532

36-
std::scoped_lock lock(task_mutex_);
37-
38-
auto status = task_.Cancel();
39-
FML_DCHECK(status == ZX_OK || status == ZX_ERR_NOT_FOUND);
40-
41-
status = task_.PostDelayed(loop_.dispatcher(), due_time);
33+
auto status = async::PostDelayedTask(
34+
loop_.dispatcher(), [this]() { RunExpiredTasksNow(); }, due_time);
4235
FML_DCHECK(status == ZX_OK);
4336
}
4437

fml/platform/fuchsia/message_loop_fuchsia.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#define FLUTTER_FML_PLATFORM_FUCHSIA_MESSAGE_LOOP_FUCHSIA_H_
77

88
#include <lib/async-loop/cpp/loop.h>
9-
#include <lib/async/cpp/task.h>
109

1110
#include "flutter/fml/macros.h"
1211
#include "flutter/fml/message_loop_impl.h"
@@ -26,8 +25,6 @@ class MessageLoopFuchsia : public MessageLoopImpl {
2625
void WakeUp(fml::TimePoint time_point) override;
2726

2827
async::Loop loop_;
29-
std::mutex task_mutex_;
30-
async::Task task_;
3128

3229
FML_FRIEND_MAKE_REF_COUNTED(MessageLoopFuchsia);
3330
FML_FRIEND_REF_COUNTED_THREAD_SAFE(MessageLoopFuchsia);

0 commit comments

Comments
 (0)