summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Maps.iOS/MapPool.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Maps.iOS/MapPool.cs')
-rw-r--r--Xamarin.Forms.Maps.iOS/MapPool.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/Xamarin.Forms.Maps.iOS/MapPool.cs b/Xamarin.Forms.Maps.iOS/MapPool.cs
new file mode 100644
index 0000000..dc8a9c4
--- /dev/null
+++ b/Xamarin.Forms.Maps.iOS/MapPool.cs
@@ -0,0 +1,25 @@
+using System.Collections.Concurrent;
+using MapKit;
+
+namespace Xamarin.Forms.Maps.iOS
+{
+ // A static pool of MKMapView instances we can reuse
+ internal class MapPool
+ {
+ static MapPool s_instance;
+ public static MapPool Instance => s_instance ?? (s_instance = new MapPool());
+
+ internal readonly ConcurrentQueue<MKMapView> Maps = new ConcurrentQueue<MKMapView>();
+
+ public static void Add(MKMapView mapView)
+ {
+ Instance.Maps.Enqueue(mapView);
+ }
+
+ public static MKMapView Get()
+ {
+ MKMapView mapView;
+ return Instance.Maps.TryDequeue(out mapView) ? mapView : null;
+ }
+ }
+} \ No newline at end of file