You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/java/software/amazon/awssdk/crt/CrtResource.java
+65-20Lines changed: 65 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -124,13 +124,15 @@ public CrtResource() {
124
124
* @param resource The resource to add a reference to
125
125
*/
126
126
publicvoidaddReferenceTo(CrtResourceresource) {
127
-
resource.addRef();
127
+
intrefCount = resource.addRef();
128
128
synchronized(this) {
129
129
referencedResources.add(resource);
130
130
}
131
131
132
132
if (debugNativeObjects) {
133
-
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource, String.format("Instance of class %s(%d) is adding a reference to instance of class %s(%d)", this.getClass().getCanonicalName(), id, resource.getClass().getCanonicalName(), resource.id));
@@ -146,9 +148,13 @@ public void removeReferenceTo(CrtResource resource) {
146
148
147
149
if (debugNativeObjects) {
148
150
if (removed) {
149
-
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource, String.format("Instance of class %s(%d) is removing a reference to instance of class %s(%d)", this.getClass().getCanonicalName(), id, resource.getClass().getCanonicalName(), resource.id));
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource, String.format("Instance of class %s(%d) erroneously tried to remove a reference to instance of class %s(%d) that it was not referencing", this.getClass().getCanonicalName(), id, resource.getClass().getCanonicalName(), resource.id));
String.format("Releasing class %s(%d)", this.getClass().getCanonicalName(), id));
213
220
214
221
synchronized(CrtResource.class) {
215
222
CRT_RESOURCES.remove(id);
@@ -236,11 +243,21 @@ public long getNativeHandle() {
236
243
/**
237
244
* Increments the reference count to this resource.
238
245
*/
239
-
publicvoidaddRef() {
240
-
refCount.incrementAndGet();
241
-
if (debugNativeObjects) {
242
-
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource, String.format("Instance of class %s(%d) is adding a reference", this.getClass().getCanonicalName(), id));
243
-
}
246
+
publicintaddRef() {
247
+
returnrefCount.incrementAndGet();
248
+
}
249
+
250
+
/**
251
+
* Increments the reference count to this resource with a description.
252
+
* @param desc Descrption string of why the reference is being incremented.
0 commit comments