summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2019-07-29 00:42:45 -0400
committerJulian Rex <julian.rex@mapbox.com>2019-08-23 16:22:08 -0400
commite164a4a2094c89a898b327109f0168c73cbba731 (patch)
treebabc13978d01e80f5e1208dc434e4c3b00d67e53
parentce52d04fb0659478125b14f509c71b2654aae904 (diff)
downloadqtlocation-mapboxgl-e164a4a2094c89a898b327109f0168c73cbba731.tar.gz
Add default signpost.
-rw-r--r--platform/darwin/src/MGLSignpost.h33
-rw-r--r--platform/darwin/src/MGLSignpost.m15
-rw-r--r--platform/ios/app/MBXViewController.m6
3 files changed, 38 insertions, 16 deletions
diff --git a/platform/darwin/src/MGLSignpost.h b/platform/darwin/src/MGLSignpost.h
index 83ff565a98..5f2eb0d625 100644
--- a/platform/darwin/src/MGLSignpost.h
+++ b/platform/darwin/src/MGLSignpost.h
@@ -11,6 +11,7 @@
#define MGL_EXPORT __attribute__((visibility ("default")))
MGL_EXPORT extern os_log_t MGLDefaultSignpostLog;
+MGL_EXPORT extern os_signpost_id_t MGLDefaultSignpost;
/**
Create an os_log_t (for use with os_signposts) with the "com.mapbox.mapbox" subsystem.
@@ -26,18 +27,26 @@ MGL_EXPORT extern os_log_t MGLDefaultSignpostLog;
*/
MGL_EXPORT extern os_log_t MGLSignpostLogCreate(const char* name);
-#define MGL_NAMED_SIGNPOST_BEGIN(log, name, ...) \
+#define MGL_NAMED_CREATE_SIGNPOST(log) \
({ \
os_signpost_id_t SIGNPOST_NAME(__LINE__) = OS_SIGNPOST_ID_INVALID; \
if (__builtin_available(iOS 12.0, macOS 10.14, *)) { \
SIGNPOST_NAME(__LINE__) = os_signpost_id_generate(log); \
- os_signpost_interval_begin(log, SIGNPOST_NAME(__LINE__), name, ##__VA_ARGS__); \
} \
SIGNPOST_NAME(__LINE__); \
})
+#define MGL_NAMED_SIGNPOST_BEGIN(log, signpost, name, ...) \
+ ({ \
+ if (signpost != OS_SIGNPOST_ID_INVALID) { \
+ if (__builtin_available(iOS 12.0, macOS 10.14, *)) { \
+ os_signpost_interval_begin(log, signpost, name, ##__VA_ARGS__); \
+ } \
+ } \
+ })
+
#define MGL_NAMED_SIGNPOST_END(log, signpost, name, ...) \
- __extension__({ \
+ ({ \
if (signpost != OS_SIGNPOST_ID_INVALID) { \
if (__builtin_available(iOS 12.0, macOS 10.14, *)) { \
os_signpost_interval_end(log, signpost, name, ##__VA_ARGS__); \
@@ -45,11 +54,12 @@ MGL_EXPORT extern os_log_t MGLSignpostLogCreate(const char* name);
} \
})
-#define MGL_NAMED_SIGNPOST_EVENT(log, name, ...) \
- __extension__({ \
- if (__builtin_available(iOS 12.0, macOS 10.14, *)) { \
- os_signpost_id_t SIGNPOST_NAME(__LINE__) = os_signpost_id_generate(log); \
- os_signpost_event_emit(log, SIGNPOST_NAME(__LINE__), name, ##__VA_ARGS__); \
+#define MGL_NAMED_SIGNPOST_EVENT(log, signpost, name, ...) \
+ ({ \
+ if (signpost != OS_SIGNPOST_ID_INVALID) { \
+ if (__builtin_available(iOS 12.0, macOS 10.14, *)) { \
+ os_signpost_event_emit(log, signpost, name, ##__VA_ARGS__); \
+ } \
} \
})
@@ -59,13 +69,16 @@ MGL_EXPORT extern os_log_t MGLSignpostLogCreate(const char* name);
//
// For example:
//
-// os_signpost_id_t signpost = MGL_SIGNPOST_BEGIN("example");
+// os_signpost_id_t signpost = MGL_CREATE_SIGNPOST();
+// MGL_SIGNPOST_BEGIN(signpost, "example");
// [self performAComputationallyExpensiveOperation];
// MGL_SIGNPOST_END(signpost, "example", "%d", numberOfWidgets);
//
// MGL_SIGNPOST_EVENT("error", "%d", errorCode);
-#define MGL_SIGNPOST_BEGIN(name, ...) MGL_NAMED_SIGNPOST_BEGIN(MGLDefaultSignpostLog, name, ##__VA_ARGS__)
+#define MGL_CREATE_SIGNPOST() MGL_NAMED_CREATE_SIGNPOST(MGLDefaultSignpostLog)
+
+#define MGL_SIGNPOST_BEGIN(signpost, name, ...) MGL_NAMED_SIGNPOST_BEGIN(MGLDefaultSignpostLog, signpost, name, ##__VA_ARGS__)
#define MGL_SIGNPOST_END(signpost, name, ...) MGL_NAMED_SIGNPOST_END(MGLDefaultSignpostLog, signpost, name, ##__VA_ARGS__)
#define MGL_SIGNPOST_EVENT(signpost, name, ...) MGL_NAMED_SIGNPOST_EVENT(MGLDefaultSignpostLog, signpost, name, ##__VA_ARGS__)
diff --git a/platform/darwin/src/MGLSignpost.m b/platform/darwin/src/MGLSignpost.m
index d421c155af..52669ad6dc 100644
--- a/platform/darwin/src/MGLSignpost.m
+++ b/platform/darwin/src/MGLSignpost.m
@@ -2,16 +2,23 @@
#include "MGLSignpost.h"
os_log_t MGLDefaultSignpostLog = NULL;
+os_signpost_id_t MGLDefaultSignpost = OS_SIGNPOST_ID_INVALID;
-void createDefaultSignpostLog(void) __attribute__((constructor));
-void destroyDefaultSignpostLog(void) __attribute__((destructor));
+void destroyDefaultSignpostVaribles(void) __attribute__((destructor));
-void destroyDefaultSignpostLog() {
+void destroyDefaultSignpostVaribles() {
MGLDefaultSignpostLog = NULL;
+ MGLDefaultSignpost = OS_SIGNPOST_ID_INVALID;
}
-void createDefaultSignpost() {
+void createDefaultSignpostVaribles(void) __attribute__((constructor));
+
+void createDefaultSignpostVaribles() {
MGLDefaultSignpostLog = MGLSignpostLogCreate("MGLSignposts");
+
+ if (__builtin_available(iOS 12.0, macOS 10.14, *)) {
+ MGLDefaultSignpost = os_signpost_id_generate(MGLDefaultSignpostLog);
+ }
}
os_log_t MGLSignpostLogCreate(const char* name) {
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 7f43f335b0..bb1a897bb1 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -563,7 +563,8 @@ CLLocationCoordinate2D randomWorldCoordinate() {
[weakSelf.pendingIdleBlocks addObject:^{
__typeof__(self) strongSelf = weakSelf;
NSLog(@"BEGIN: query-roads-batch");
- os_signpost_id_t signpost = MGL_SIGNPOST_BEGIN("query-roads-batch");
+ os_signpost_id_t signpost = MGL_CREATE_SIGNPOST();
+ MGL_SIGNPOST_BEGIN(signpost, "query-roads-batch");
for (int i = 0; i < 10; i++) {
[strongSelf queryRoads];
}
@@ -1756,7 +1757,8 @@ CLLocationCoordinate2D randomWorldCoordinate() {
- (void)queryRoads
{
- os_signpost_id_t signpost = MGL_SIGNPOST_BEGIN("query-roads");
+ os_signpost_id_t signpost = MGL_CREATE_SIGNPOST();
+ MGL_SIGNPOST_BEGIN(signpost, "query-roads");
NSArray *roadStyleLayerIdentifiers = [self.mapView.style.roadStyleLayers valueForKey:@"identifier"];
NSArray *visibleRoadFeatures = [self.mapView visibleFeaturesInRect:self.mapView.bounds inStyleLayersWithIdentifiers:[NSSet setWithArray:roadStyleLayerIdentifiers]];