Skip to content

Commit

Permalink
Merge flutter/synchronization contents into fml. (flutter#8525)
Browse files Browse the repository at this point in the history
When flutter/synchronization was first authored, we did not own fml (it was called fxl then). Now we do, so use a single spot for such utilities. The pipeline was meant to be a general purpose utility that was only ever used by the animator (it even has animator specific tracing), so move that to shell instead (where the animator resides).
  • Loading branch information
chinmaygarde authored Apr 10, 2019
1 parent 905c571 commit e356dbc
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 74 deletions.
1 change: 0 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ group("flutter") {
"$flutter_root/runtime:runtime_unittests",
"$flutter_root/shell/common:shell_unittests",
"$flutter_root/shell/platform/embedder:embedder_unittests",
"$flutter_root/synchronization:synchronization_unittests",
"$flutter_root/third_party/txt:txt_unittests",
]

Expand Down
10 changes: 5 additions & 5 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ FILE: ../../../flutter/fml/synchronization/atomic_object.h
FILE: ../../../flutter/fml/synchronization/count_down_latch.cc
FILE: ../../../flutter/fml/synchronization/count_down_latch.h
FILE: ../../../flutter/fml/synchronization/count_down_latch_unittests.cc
FILE: ../../../flutter/fml/synchronization/semaphore.cc
FILE: ../../../flutter/fml/synchronization/semaphore.h
FILE: ../../../flutter/fml/synchronization/semaphore_unittest.cc
FILE: ../../../flutter/fml/synchronization/shared_mutex.h
FILE: ../../../flutter/fml/synchronization/shared_mutex_std.cc
FILE: ../../../flutter/fml/synchronization/shared_mutex_std.h
Expand Down Expand Up @@ -417,6 +420,8 @@ FILE: ../../../flutter/shell/common/isolate_configuration.cc
FILE: ../../../flutter/shell/common/isolate_configuration.h
FILE: ../../../flutter/shell/common/persistent_cache.cc
FILE: ../../../flutter/shell/common/persistent_cache.h
FILE: ../../../flutter/shell/common/pipeline.cc
FILE: ../../../flutter/shell/common/pipeline.h
FILE: ../../../flutter/shell/common/platform_view.cc
FILE: ../../../flutter/shell/common/platform_view.h
FILE: ../../../flutter/shell/common/rasterizer.cc
Expand Down Expand Up @@ -717,11 +722,6 @@ FILE: ../../../flutter/shell/platform/glfw/text_input_plugin.cc
FILE: ../../../flutter/shell/platform/glfw/text_input_plugin.h
FILE: ../../../flutter/sky/packages/flutter_services/lib/empty.dart
FILE: ../../../flutter/sky/tools/roll/patches/chromium/android_build.patch
FILE: ../../../flutter/synchronization/pipeline.cc
FILE: ../../../flutter/synchronization/pipeline.h
FILE: ../../../flutter/synchronization/semaphore.cc
FILE: ../../../flutter/synchronization/semaphore.h
FILE: ../../../flutter/synchronization/semaphore_unittest.cc
FILE: ../../../flutter/third_party/txt/src/txt/platform.cc
FILE: ../../../flutter/third_party/txt/src/txt/platform.h
FILE: ../../../flutter/third_party/txt/src/txt/platform_android.cc
Expand Down
1 change: 0 additions & 1 deletion flow/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ source_set("flow") {
deps = [
"$flutter_root/common",
"$flutter_root/fml",
"$flutter_root/synchronization",
"//third_party/skia",
]

Expand Down
3 changes: 3 additions & 0 deletions fml/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ source_set("fml") {
"synchronization/atomic_object.h",
"synchronization/count_down_latch.cc",
"synchronization/count_down_latch.h",
"synchronization/semaphore.cc",
"synchronization/semaphore.h",
"synchronization/shared_mutex.h",
"synchronization/thread_annotations.h",
"synchronization/waitable_event.cc",
Expand Down Expand Up @@ -188,6 +190,7 @@ executable("fml_unittests") {
"paths_unittests.cc",
"string_view_unittest.cc",
"synchronization/count_down_latch_unittests.cc",
"synchronization/semaphore_unittest.cc",
"synchronization/thread_annotations_unittest.cc",
"synchronization/waitable_event_unittest.cc",
"thread_local_unittests.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/synchronization/semaphore.h"
#include "flutter/fml/synchronization/semaphore.h"

#include "flutter/fml/build_config.h"
#include "flutter/fml/logging.h"

#if OS_MACOSX
#include <dispatch/dispatch.h>

namespace flutter {
namespace fml {

class PlatformSemaphore {
public:
Expand Down Expand Up @@ -50,12 +50,12 @@ class PlatformSemaphore {
FML_DISALLOW_COPY_AND_ASSIGN(PlatformSemaphore);
};

} // namespace flutter
} // namespace fml

#elif OS_WIN
#include <windows.h>

namespace flutter {
namespace fml {

class PlatformSemaphore {
public:
Expand Down Expand Up @@ -91,13 +91,13 @@ class PlatformSemaphore {
FML_DISALLOW_COPY_AND_ASSIGN(PlatformSemaphore);
};

} // namespace flutter
} // namespace fml

#else
#include <semaphore.h>
#include "flutter/fml/eintr_wrapper.h"

namespace flutter {
namespace fml {

class PlatformSemaphore {
public:
Expand Down Expand Up @@ -140,11 +140,11 @@ class PlatformSemaphore {
FML_DISALLOW_COPY_AND_ASSIGN(PlatformSemaphore);
};

} // namespace flutter
} // namespace fml

#endif

namespace flutter {
namespace fml {

Semaphore::Semaphore(uint32_t count) : _impl(new PlatformSemaphore(count)) {}

Expand All @@ -162,4 +162,4 @@ void Semaphore::Signal() {
return _impl->Signal();
}

} // namespace flutter
} // namespace fml
10 changes: 5 additions & 5 deletions synchronization/semaphore.h → fml/synchronization/semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SYNCHRONIZATION_SEMAPHORE_H_
#define SYNCHRONIZATION_SEMAPHORE_H_
#ifndef FLUTTER_FML_SYNCHRONIZATION_SEMAPHORE_H_
#define FLUTTER_FML_SYNCHRONIZATION_SEMAPHORE_H_

#include <memory>

#include "flutter/fml/compiler_specific.h"
#include "flutter/fml/macros.h"

namespace flutter {
namespace fml {

class PlatformSemaphore;

Expand All @@ -33,6 +33,6 @@ class Semaphore {
FML_DISALLOW_COPY_AND_ASSIGN(Semaphore);
};

} // namespace flutter
} // namespace fml

#endif // SYNCHRONIZATION_SEMAPHORE_H_
#endif // FLUTTER_FML_SYNCHRONIZATION_SEMAPHORE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

#include <thread>

#include "flutter/synchronization/semaphore.h"
#include "flutter/fml/synchronization/semaphore.h"
#include "gtest/gtest.h"

TEST(SemaphoreTest, SimpleValidity) {
flutter::Semaphore sem(100);
fml::Semaphore sem(100);
ASSERT_TRUE(sem.IsValid());
}

TEST(SemaphoreTest, WaitOnZero) {
flutter::Semaphore sem(0);
fml::Semaphore sem(0);
ASSERT_FALSE(sem.TryWait());
}

TEST(SemaphoreTest, WaitOnZeroSignalThenWait) {
flutter::Semaphore sem(0);
fml::Semaphore sem(0);
ASSERT_FALSE(sem.TryWait());
std::thread thread([&sem]() { sem.Signal(); });
thread.join();
Expand Down
3 changes: 2 additions & 1 deletion shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ source_set("common") {
"isolate_configuration.h",
"persistent_cache.cc",
"persistent_cache.h",
"pipeline.cc",
"pipeline.h",
"platform_view.cc",
"platform_view.h",
"rasterizer.cc",
Expand Down Expand Up @@ -99,7 +101,6 @@ source_set("common") {
"$flutter_root/fml",
"$flutter_root/lib/ui",
"$flutter_root/runtime",
"$flutter_root/synchronization",
"//third_party/dart/runtime:dart_api",
"//third_party/skia",
]
Expand Down
6 changes: 3 additions & 3 deletions shell/common/animator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include "flutter/common/task_runners.h"
#include "flutter/fml/memory/ref_ptr.h"
#include "flutter/fml/memory/weak_ptr.h"
#include "flutter/fml/synchronization/semaphore.h"
#include "flutter/fml/time/time_point.h"
#include "flutter/shell/common/pipeline.h"
#include "flutter/shell/common/rasterizer.h"
#include "flutter/shell/common/vsync_waiter.h"
#include "flutter/synchronization/pipeline.h"
#include "flutter/synchronization/semaphore.h"

namespace flutter {

Expand Down Expand Up @@ -74,7 +74,7 @@ class Animator final {
fml::TimePoint last_begin_frame_time_;
int64_t dart_frame_deadline_;
fml::RefPtr<LayerTreePipeline> layer_tree_pipeline_;
Semaphore pending_frame_semaphore_;
fml::Semaphore pending_frame_semaphore_;
LayerTreePipeline::ProducerContinuation producer_continuation_;
int64_t frame_number_;
bool paused_;
Expand Down
2 changes: 1 addition & 1 deletion synchronization/pipeline.cc → shell/common/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/synchronization/pipeline.h"
#include "flutter/shell/common/pipeline.h"

namespace flutter {

Expand Down
13 changes: 6 additions & 7 deletions synchronization/pipeline.h → shell/common/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SYNCHRONIZATION_PIPELINE_H_
#define SYNCHRONIZATION_PIPELINE_H_
#ifndef FLUTTER_SHELL_COMMON_PIPELINE_H_
#define FLUTTER_SHELL_COMMON_PIPELINE_H_

#include "flutter/fml/macros.h"
#include "flutter/fml/memory/ref_counted.h"
#include "flutter/fml/synchronization/semaphore.h"
#include "flutter/fml/trace_event.h"
#include "flutter/synchronization/pipeline.h"
#include "flutter/synchronization/semaphore.h"

#include <memory>
#include <mutex>
Expand Down Expand Up @@ -142,8 +141,8 @@ class Pipeline : public fml::RefCountedThreadSafe<Pipeline<R>> {
}

private:
Semaphore empty_;
Semaphore available_;
fml::Semaphore empty_;
fml::Semaphore available_;
std::mutex queue_mutex_;
std::queue<std::pair<ResourcePtr, size_t>> queue_;

Expand All @@ -162,4 +161,4 @@ class Pipeline : public fml::RefCountedThreadSafe<Pipeline<R>> {

} // namespace flutter

#endif // SYNCHRONIZATION_PIPELINE_H_
#endif // FLUTTER_SHELL_COMMON_PIPELINE_H_
2 changes: 1 addition & 1 deletion shell/common/rasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "flutter/fml/memory/weak_ptr.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/lib/ui/snapshot_delegate.h"
#include "flutter/shell/common/pipeline.h"
#include "flutter/shell/common/surface.h"
#include "flutter/synchronization/pipeline.h"

namespace flutter {

Expand Down
1 change: 0 additions & 1 deletion shell/gpu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ gpu_common_deps = [
"$flutter_root/flow",
"$flutter_root/fml",
"$flutter_root/shell/common",
"$flutter_root/synchronization",
"//third_party/skia",
]

Expand Down
32 changes: 0 additions & 32 deletions synchronization/BUILD.gn

This file was deleted.

3 changes: 0 additions & 3 deletions testing/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ echo "Running runtime_unittests..."
echo "Running shell_unittests..."
"$HOST_DIR/shell_unittests"

echo "Running synchronization_unittests..."
"$HOST_DIR/synchronization_unittests"

echo "Running txt_unittests..."
"$HOST_DIR/txt_unittests" --font-directory="$BUILDROOT_DIR/flutter/third_party/txt/third_party/fonts"

Expand Down

0 comments on commit e356dbc

Please sign in to comment.