Loading...
Searching...
No Matches
RouteSession.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
16public abstract class RouteSession {
25 public abstract void addRouteListener(AsyncRouteListener listener);
26
33 public abstract void removeRouteListener(AsyncRouteListener listener);
34
35 private static final class CppProxy extends RouteSession
36 {
37 private final long nativeRef;
38 private final AtomicBoolean destroyed = new AtomicBoolean(false);
39
40 private CppProxy(long nativeRef)
41 {
42 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
43 this.nativeRef = nativeRef;
44 }
45
46 private native void nativeDestroy(long nativeRef);
47 public void _djinni_private_destroy()
48 {
49 boolean destroyed = this.destroyed.getAndSet(true);
50 if (!destroyed) nativeDestroy(this.nativeRef);
51 }
52 protected void finalize() throws java.lang.Throwable
53 {
54 _djinni_private_destroy();
55 super.finalize();
56 }
57
58 // RouteSession methods
59
60 @Override
61 public void addRouteListener(AsyncRouteListener listener)
62 {
63 assert !this.destroyed.get() : "trying to use a destroyed object";
64 native_addRouteListener(this.nativeRef, listener);
65 }
66 private native void native_addRouteListener(long _nativeRef, AsyncRouteListener listener);
67
68 @Override
69 public void removeRouteListener(AsyncRouteListener listener)
70 {
71 assert !this.destroyed.get() : "trying to use a destroyed object";
72 native_removeRouteListener(this.nativeRef, listener);
73 }
74 private native void native_removeRouteListener(long _nativeRef, AsyncRouteListener listener);
75 }
76}