Loading...
Searching...
No Matches
AsyncRouteManager.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
16public abstract class AsyncRouteManager {
32 public abstract RouteSession createRouteSession(LocationPoint wayPoint, RouteOptions routeOptions);
33
56 public abstract RouteSession createRouteSessionWithTag(LocationPoint wayPoint, RouteOptions routeOptions, String tag);
57
71 public abstract void cancelRouteSession(RouteSession session);
72
73 private static final class CppProxy extends AsyncRouteManager
74 {
75 private final long nativeRef;
76 private final AtomicBoolean destroyed = new AtomicBoolean(false);
77
78 private CppProxy(long nativeRef)
79 {
80 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
81 this.nativeRef = nativeRef;
82 }
83
84 private native void nativeDestroy(long nativeRef);
85 public void _djinni_private_destroy()
86 {
87 boolean destroyed = this.destroyed.getAndSet(true);
88 if (!destroyed) nativeDestroy(this.nativeRef);
89 }
90 protected void finalize() throws java.lang.Throwable
91 {
92 _djinni_private_destroy();
93 super.finalize();
94 }
95
96 // AsyncRouteManager methods
97
98 @Override
99 public RouteSession createRouteSession(LocationPoint wayPoint, RouteOptions routeOptions)
100 {
101 assert !this.destroyed.get() : "trying to use a destroyed object";
102 return native_createRouteSession(this.nativeRef, wayPoint, routeOptions);
103 }
104 private native RouteSession native_createRouteSession(long _nativeRef, LocationPoint wayPoint, RouteOptions routeOptions);
105
106 @Override
107 public RouteSession createRouteSessionWithTag(LocationPoint wayPoint, RouteOptions routeOptions, String tag)
108 {
109 assert !this.destroyed.get() : "trying to use a destroyed object";
110 return native_createRouteSessionWithTag(this.nativeRef, wayPoint, routeOptions, tag);
111 }
112 private native RouteSession native_createRouteSessionWithTag(long _nativeRef, LocationPoint wayPoint, RouteOptions routeOptions, String tag);
113
114 @Override
115 public void cancelRouteSession(RouteSession session)
116 {
117 assert !this.destroyed.get() : "trying to use a destroyed object";
118 native_cancelRouteSession(this.nativeRef, session);
119 }
120 private native void native_cancelRouteSession(long _nativeRef, RouteSession session);
121 }
122}