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
38 public abstract RouteSession createRouteSessionWithTag(LocationPoint wayPoint, RouteOptions routeOptions, String tag);
39
44 public abstract void cancelRouteSession(RouteSession session);
45
46 private static final class CppProxy extends AsyncRouteManager
47 {
48 private final long nativeRef;
49 private final AtomicBoolean destroyed = new AtomicBoolean(false);
50
51 private CppProxy(long nativeRef)
52 {
53 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
54 this.nativeRef = nativeRef;
55 }
56
57 private native void nativeDestroy(long nativeRef);
58 public void _djinni_private_destroy()
59 {
60 boolean destroyed = this.destroyed.getAndSet(true);
61 if (!destroyed) nativeDestroy(this.nativeRef);
62 }
63 protected void finalize() throws java.lang.Throwable
64 {
65 _djinni_private_destroy();
66 super.finalize();
67 }
68
69 // AsyncRouteManager methods
70
71 @Override
72 public RouteSession createRouteSession(LocationPoint wayPoint, RouteOptions routeOptions)
73 {
74 assert !this.destroyed.get() : "trying to use a destroyed object";
75 return native_createRouteSession(this.nativeRef, wayPoint, routeOptions);
76 }
77 private native RouteSession native_createRouteSession(long _nativeRef, LocationPoint wayPoint, RouteOptions routeOptions);
78
79 @Override
80 public RouteSession createRouteSessionWithTag(LocationPoint wayPoint, RouteOptions routeOptions, String tag)
81 {
82 assert !this.destroyed.get() : "trying to use a destroyed object";
83 return native_createRouteSessionWithTag(this.nativeRef, wayPoint, routeOptions, tag);
84 }
85 private native RouteSession native_createRouteSessionWithTag(long _nativeRef, LocationPoint wayPoint, RouteOptions routeOptions, String tag);
86
87 @Override
88 public void cancelRouteSession(RouteSession session)
89 {
90 assert !this.destroyed.get() : "trying to use a destroyed object";
91 native_cancelRouteSession(this.nativeRef, session);
92 }
93 private native void native_cancelRouteSession(long _nativeRef, RouteSession session);
94 }
95}