[macos,ios] initialize util::RunLoop in SDK rather than by default
This commit is contained in:
committed by
John Firebaugh
parent
7bcb04a609
commit
08809b4d44
@@ -8,7 +8,6 @@ namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
static ThreadLocal<RunLoop>& current = *new ThreadLocal<RunLoop>;
|
||||
static RunLoop mainRunLoop;
|
||||
|
||||
class RunLoop::Impl {
|
||||
public:
|
||||
@@ -22,6 +21,7 @@ RunLoop* RunLoop::Get() {
|
||||
|
||||
RunLoop::RunLoop(Type)
|
||||
: impl(std::make_unique<Impl>()) {
|
||||
assert(!current.get());
|
||||
current.set(this);
|
||||
impl->async = std::make_unique<AsyncTask>(std::bind(&RunLoop::process, this));
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <mbgl/util/projection.hpp>
|
||||
#include <mbgl/util/default_styles.hpp>
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
#import <mbgl/util/run_loop.hpp>
|
||||
|
||||
#import "Mapbox.h"
|
||||
#import "MGLFeature_Private.h"
|
||||
@@ -126,6 +127,11 @@ enum { MGLAnnotationTagNotFound = UINT32_MAX };
|
||||
/// the annotation itself.
|
||||
typedef std::map<MGLAnnotationTag, MGLAnnotationContext> MGLAnnotationContextMap;
|
||||
|
||||
/// Initializes the run loop shim that lives on the main thread.
|
||||
void MGLinitializeRunLoop() {
|
||||
static mbgl::util::RunLoop mainRunLoop;
|
||||
}
|
||||
|
||||
mbgl::util::UnitBezier MGLUnitBezierForMediaTimingFunction(CAMediaTimingFunction *function)
|
||||
{
|
||||
if ( ! function)
|
||||
@@ -357,6 +363,8 @@ public:
|
||||
|
||||
- (void)commonInit
|
||||
{
|
||||
MGLinitializeRunLoop();
|
||||
|
||||
_isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent;
|
||||
_opaque = YES;
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#import <mbgl/math/wrap.hpp>
|
||||
#import <mbgl/util/constants.hpp>
|
||||
#import <mbgl/util/chrono.hpp>
|
||||
#import <mbgl/util/run_loop.hpp>
|
||||
|
||||
#import <unordered_map>
|
||||
#import <unordered_set>
|
||||
@@ -112,6 +113,11 @@ NSImage *MGLDefaultMarkerImage() {
|
||||
return [[NSImage alloc] initWithContentsOfFile:path];
|
||||
}
|
||||
|
||||
/// Initializes the run loop shim that lives on the main thread.
|
||||
void MGLinitializeRunLoop() {
|
||||
static mbgl::util::RunLoop mainRunLoop;
|
||||
}
|
||||
|
||||
/// Converts a media timing function into a unit bezier object usable in mbgl.
|
||||
mbgl::util::UnitBezier MGLUnitBezierForMediaTimingFunction(CAMediaTimingFunction *function) {
|
||||
if (!function) {
|
||||
@@ -234,6 +240,8 @@ public:
|
||||
}
|
||||
|
||||
- (void)commonInit {
|
||||
MGLinitializeRunLoop();
|
||||
|
||||
_isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent;
|
||||
|
||||
// Set up cross-platform controllers and resources.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <mbgl/tile/tile_loader_impl.hpp>
|
||||
|
||||
#include <mbgl/actor/thread_pool.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/map/transform.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/style/update_parameters.hpp>
|
||||
@@ -15,6 +16,7 @@ class RasterTileTest {
|
||||
public:
|
||||
FakeFileSource fileSource;
|
||||
TransformState transformState;
|
||||
util::RunLoop loop;
|
||||
ThreadPool threadPool { 1 };
|
||||
AnnotationManager annotationManager { 1.0 };
|
||||
style::Style style { fileSource, 1.0 };
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <mbgl/tile/tile_loader_impl.hpp>
|
||||
|
||||
#include <mbgl/actor/thread_pool.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/map/transform.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/style/update_parameters.hpp>
|
||||
@@ -15,6 +16,7 @@ class VectorTileTest {
|
||||
public:
|
||||
FakeFileSource fileSource;
|
||||
TransformState transformState;
|
||||
util::RunLoop loop;
|
||||
ThreadPool threadPool { 1 };
|
||||
AnnotationManager annotationManager { 1.0 };
|
||||
style::Style style { fileSource, 1.0 };
|
||||
|
||||
Reference in New Issue
Block a user