< prev index next >

src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template

Print this page

 86     public boolean closeScope(Scope scope) {
 87         return closeScope0(scope, Scope.ScopedAccessError.INSTANCE);
 88     }
 89 
 90     native boolean closeScope0(Scope scope, Scope.ScopedAccessError exception);
 91 
 92     private ScopedMemoryAccess() {}
 93 
 94     private static final ScopedMemoryAccess theScopedMemoryAccess = new ScopedMemoryAccess();
 95 
 96     public static ScopedMemoryAccess getScopedMemoryAccess() {
 97         return theScopedMemoryAccess;
 98     }
 99 
100     /**
101      * Scope interface used during scoped memory access operations. A scope can be thought of as an object
102      * which embodies the temporal checks associated with a given memory region.
103      */
104     public interface Scope {
105 
106        interface Handle {
107             Scope scope();
108         }
109 
110         void checkValidState();
111 
112         Thread ownerThread();
113 
114         boolean isImplicit();
115 
116         Handle acquire();
117 
118         void release(Handle handle);
119 
120         /**
121          * Error thrown when memory access fails because the memory has already been released.
122          * Note: for performance reasons, this exception is never created by client; instead a shared instance
123          * is thrown (sometimes, this instance can be thrown asynchronously inside VM code). For this reason,
124          * it is important for clients to always catch this exception and throw a regular exception instead
125          * (which contains full stack information).
126          */
127         final class ScopedAccessError extends Error {
128             private ScopedAccessError() {
129                 super("Attempt to access an already released memory resource", null, false, false);
130             }
131             static final long serialVersionUID = 1L;
132 
133             public static final ScopedAccessError INSTANCE = new ScopedAccessError();
134         }
135     }
136 
137     @Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
138     @Retention(RetentionPolicy.RUNTIME)

 86     public boolean closeScope(Scope scope) {
 87         return closeScope0(scope, Scope.ScopedAccessError.INSTANCE);
 88     }
 89 
 90     native boolean closeScope0(Scope scope, Scope.ScopedAccessError exception);
 91 
 92     private ScopedMemoryAccess() {}
 93 
 94     private static final ScopedMemoryAccess theScopedMemoryAccess = new ScopedMemoryAccess();
 95 
 96     public static ScopedMemoryAccess getScopedMemoryAccess() {
 97         return theScopedMemoryAccess;
 98     }
 99 
100     /**
101      * Scope interface used during scoped memory access operations. A scope can be thought of as an object
102      * which embodies the temporal checks associated with a given memory region.
103      */
104     public interface Scope {
105 




106         void checkValidState();
107 
108         Thread ownerThread();
109 
110         void acquire0();


111 
112         void release0();
113 
114         /**
115          * Error thrown when memory access fails because the memory has already been released.
116          * Note: for performance reasons, this exception is never created by client; instead a shared instance
117          * is thrown (sometimes, this instance can be thrown asynchronously inside VM code). For this reason,
118          * it is important for clients to always catch this exception and throw a regular exception instead
119          * (which contains full stack information).
120          */
121         final class ScopedAccessError extends Error {
122             private ScopedAccessError() {
123                 super("Attempt to access an already released memory resource", null, false, false);
124             }
125             static final long serialVersionUID = 1L;
126 
127             public static final ScopedAccessError INSTANCE = new ScopedAccessError();
128         }
129     }
130 
131     @Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
132     @Retention(RetentionPolicy.RUNTIME)
< prev index next >