X Tutup
Skip to content

Commit 4e64cb9

Browse files
authored
Rename Context to NativeContext (realm#4597)
1 parent 523ba04 commit 4e64cb9

File tree

10 files changed

+23
-23
lines changed

10 files changed

+23
-23
lines changed

realm/realm-library/src/main/java/io/realm/internal/CheckedRow.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class CheckedRow extends UncheckedRow {
3333
@SuppressWarnings({"unused", "FieldCanBeLocal"})
3434
private UncheckedRow originalRow;
3535

36-
private CheckedRow(Context context, Table parent, long nativePtr) {
36+
private CheckedRow(NativeContext context, Table parent, long nativePtr) {
3737
super(context, parent, nativePtr);
3838
}
3939

@@ -50,7 +50,7 @@ private CheckedRow(UncheckedRow row) {
5050
* @param index the index of the row.
5151
* @return an instance of Row for the table and index specified.
5252
*/
53-
public static CheckedRow get(Context context, Table table, long index) {
53+
public static CheckedRow get(NativeContext context, Table table, long index) {
5454
long nativeRowPointer = table.nativeGetRowPtr(table.getNativePtr(), index);
5555
return new CheckedRow(context, table, nativeRowPointer);
5656
}
@@ -63,7 +63,7 @@ public static CheckedRow get(Context context, Table table, long index) {
6363
* @param index the index of the row.
6464
* @return a checked instance of {@link Row} for the {@link LinkView} and index specified.
6565
*/
66-
public static CheckedRow get(Context context, LinkView linkView, long index) {
66+
public static CheckedRow get(NativeContext context, LinkView linkView, long index) {
6767
long nativeRowPointer = linkView.nativeGetRow(linkView.getNativePtr(), index);
6868
return new CheckedRow(context, linkView.getTargetTable(), nativeRowPointer);
6969
}

realm/realm-library/src/main/java/io/realm/internal/Collection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public void set(T object) {
259259
private final long nativePtr;
260260
private static final long nativeFinalizerPtr = nativeGetFinalizerPtr();
261261
private final SharedRealm sharedRealm;
262-
private final Context context;
262+
private final NativeContext context;
263263
private final Table table;
264264
private boolean loaded;
265265
private boolean isSnapshot = false;

realm/realm-library/src/main/java/io/realm/internal/CollectionChangeSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class CollectionChangeSet implements OrderedCollectionChangeSet, NativeOb
4444

4545
public CollectionChangeSet(long nativePtr) {
4646
this.nativePtr = nativePtr;
47-
Context.dummyContext.addReference(this);
47+
NativeContext.dummyContext.addReference(this);
4848
}
4949

5050
/**

realm/realm-library/src/main/java/io/realm/internal/LinkView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
*/
2525
public class LinkView implements NativeObject {
2626

27-
private final Context context;
27+
private final NativeContext context;
2828
final Table parent;
2929
final long columnIndexInParent;
3030
private final long nativePtr;
3131
private static final long nativeFinalizerPtr = nativeGetFinalizerPtr();
3232

33-
public LinkView(Context context, Table parent, long columnIndexInParent, long nativeLinkViewPtr) {
33+
public LinkView(NativeContext context, Table parent, long columnIndexInParent, long nativeLinkViewPtr) {
3434
this.context = context;
3535
this.parent = parent;
3636
this.columnIndexInParent = columnIndexInParent;

realm/realm-library/src/main/java/io/realm/internal/Context.java renamed to realm/realm-library/src/main/java/io/realm/internal/NativeContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121

2222
// Currently we free native objects in two threads, the SharedGroup is freed in the caller thread, others are freed in
2323
// RealmFinalizingDaemon thread. And the destruction in both threads are locked by the corresponding context.
24-
// The purpose of locking on Context is:
24+
// The purpose of locking on NativeContext is:
2525
// Destruction of SharedGroup (and hence Group and Table) is currently not thread-safe with respect to destruction of
2626
// other accessors, you have to ensure mutual exclusion. This is also illustrated by the use of locks in the test
2727
// test_destructor_thread_safety.cpp. Explicit call of SharedGroup::close() or Table::detach() is also not thread-safe
2828
// with respect to destruction of other accessors.
29-
public class Context {
29+
public class NativeContext {
3030
private final static ReferenceQueue<NativeObject> referenceQueue = new ReferenceQueue<NativeObject>();
3131
private final static Thread finalizingThread = new Thread(new FinalizerRunnable(referenceQueue));
3232
// Dummy context which will be used by native objects which's destructors are always thread safe.
33-
final static Context dummyContext = new Context();
33+
final static NativeContext dummyContext = new NativeContext();
3434

3535
static {
3636
finalizingThread.setName("RealmFinalizingDaemon");

realm/realm-library/src/main/java/io/realm/internal/NativeObjectReference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ synchronized void remove(NativeObjectReference ref) {
6363
private final long nativePtr;
6464
// The pointer to the native finalize function
6565
private final long nativeFinalizerPtr;
66-
private final Context context;
66+
private final NativeContext context;
6767
private NativeObjectReference prev;
6868
private NativeObjectReference next;
6969

7070
private static ReferencePool referencePool = new ReferencePool();
7171

72-
NativeObjectReference(Context context,
72+
NativeObjectReference(NativeContext context,
7373
NativeObject referent,
7474
ReferenceQueue<? super NativeObject> referenceQueue) {
7575
super(referent, referenceQueue);

realm/realm-library/src/main/java/io/realm/internal/SharedRealm.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public interface SchemaVersionListener {
177177
private final RealmConfiguration configuration;
178178

179179
final private long nativePtr;
180-
final Context context;
180+
final NativeContext context;
181181
private long lastSchemaVersion;
182182
private final SchemaVersionListener schemaChangeListener;
183183

@@ -193,7 +193,7 @@ private SharedRealm(long nativeConfigPtr,
193193
this.capabilities = capabilities;
194194
this.realmNotifier = realmNotifier;
195195
this.schemaChangeListener = schemaVersionListener;
196-
context = new Context();
196+
context = new NativeContext();
197197
context.addReference(this);
198198
this.lastSchemaVersion = schemaVersionListener == null ? -1L : getSchemaVersion();
199199
nativeSetAutoRefresh(nativePtr, capabilities.canDeliverNotification());

realm/realm-library/src/main/java/io/realm/internal/Table.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ enum PivotType {
6060

6161
private long nativePtr;
6262
private static final long nativeFinalizerPtr = nativeGetFinalizerPtr();
63-
final Context context;
63+
final NativeContext context;
6464
private final SharedRealm sharedRealm;
6565
private long cachedPrimaryKeyColumnIndex = NO_MATCH;
6666

@@ -69,7 +69,7 @@ enum PivotType {
6969
* allowed only for empty tables. It creates a native reference of the object and keeps a reference to it.
7070
*/
7171
public Table() {
72-
this.context = new Context();
72+
this.context = new NativeContext();
7373
// Native methods work will be initialized here. Generated classes will
7474
// have nothing to do with the native functions. Generated Java Table
7575
// classes will work as a wrapper on top of table.

realm/realm-library/src/main/java/io/realm/internal/TableQuery.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ public class TableQuery implements NativeObject {
2828
protected long nativePtr;
2929
private static final long nativeFinalizerPtr = nativeGetFinalizerPtr();
3030
protected final Table table;
31-
private final Context context;
31+
private final NativeContext context;
3232

3333
// All actions (find(), findAll(), sum(), etc.) must call validateQuery() before performing
3434
// the actual action. The other methods must set queryValidated to false in order to enforce
3535
// the first action to validate the syntax of the query.
3636
private boolean queryValidated = true;
3737

3838
// TODO: Can we protect this?
39-
public TableQuery(Context context, Table table, long nativeQueryPtr) {
39+
public TableQuery(NativeContext context, Table table, long nativeQueryPtr) {
4040
if (DEBUG) {
4141
System.err.println("++++++ new TableQuery, ptr= " + nativeQueryPtr);
4242
}

realm/realm-library/src/main/java/io/realm/internal/UncheckedRow.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
public class UncheckedRow implements NativeObject, Row {
3434
private static final long nativeFinalizerPtr = nativeGetFinalizerPtr();
3535

36-
private final Context context; // This is only kept because for now it's needed by the constructor of LinkView
36+
private final NativeContext context; // This is only kept because for now it's needed by the constructor of LinkView
3737
private final Table parent;
3838
private final long nativePtr;
3939

40-
UncheckedRow(Context context, Table parent, long nativePtr) {
40+
UncheckedRow(NativeContext context, Table parent, long nativePtr) {
4141
this.context = context;
4242
this.parent = parent;
4343
this.nativePtr = nativePtr;
@@ -71,7 +71,7 @@ public long getNativeFinalizerPtr() {
7171
* @param index the index of the row.
7272
* @return an instance of Row for the table and index specified.
7373
*/
74-
static UncheckedRow getByRowIndex(Context context, Table table, long index) {
74+
static UncheckedRow getByRowIndex(NativeContext context, Table table, long index) {
7575
long nativeRowPointer = table.nativeGetRowPtr(table.getNativePtr(), index);
7676
return new UncheckedRow(context, table, nativeRowPointer);
7777
}
@@ -84,7 +84,7 @@ static UncheckedRow getByRowIndex(Context context, Table table, long index) {
8484
* @param nativeRowPointer pointer of a row.
8585
* @return an instance of Row for the table and row specified.
8686
*/
87-
static UncheckedRow getByRowPointer(Context context, Table table, long nativeRowPointer) {
87+
static UncheckedRow getByRowPointer(NativeContext context, Table table, long nativeRowPointer) {
8888
return new UncheckedRow(context, table, nativeRowPointer);
8989
}
9090

@@ -96,7 +96,7 @@ static UncheckedRow getByRowPointer(Context context, Table table, long nativeRow
9696
* @param index the index of the row.
9797
* @return an instance of Row for the LinkView and index specified.
9898
*/
99-
static UncheckedRow getByRowIndex(Context context, LinkView linkView, long index) {
99+
static UncheckedRow getByRowIndex(NativeContext context, LinkView linkView, long index) {
100100
long nativeRowPointer = linkView.nativeGetRow(linkView.getNativePtr(), index);
101101
return new UncheckedRow(context, linkView.getTargetTable(), nativeRowPointer);
102102
}

0 commit comments

Comments
 (0)
X Tutup