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 {
23 public abstract RouteSession createRouteSession(LocationPoint wayPoint, RouteOptions routeOptions);
24
29 public abstract void cancelRouteSession(RouteSession session);
30
31 private static final class CppProxy extends AsyncRouteManager
32 {
33 private final long nativeRef;
34 private final AtomicBoolean destroyed = new AtomicBoolean(false);
35
36 private CppProxy(long nativeRef)
37 {
38 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
39 this.nativeRef = nativeRef;
40 }
41
42 private native void nativeDestroy(long nativeRef);
43 public void _djinni_private_destroy()
44 {
45 boolean destroyed = this.destroyed.getAndSet(true);
46 if (!destroyed) nativeDestroy(this.nativeRef);
47 }
48 protected void finalize() throws java.lang.Throwable
49 {
50 _djinni_private_destroy();
51 super.finalize();
52 }
53
54 // AsyncRouteManager methods
55
56 @Override
57 public RouteSession createRouteSession(LocationPoint wayPoint, RouteOptions routeOptions)
58 {
59 assert !this.destroyed.get() : "trying to use a destroyed object";
60 return native_createRouteSession(this.nativeRef, wayPoint, routeOptions);
61 }
62 private native RouteSession native_createRouteSession(long _nativeRef, LocationPoint wayPoint, RouteOptions routeOptions);
63
64 @Override
65 public void cancelRouteSession(RouteSession session)
66 {
67 assert !this.destroyed.get() : "trying to use a destroyed object";
68 native_cancelRouteSession(this.nativeRef, session);
69 }
70 private native void native_cancelRouteSession(long _nativeRef, RouteSession session);
71 }
72}