Sync fbjni copy with upstream

Summary: Merge upstream fbjni into our copy.

Reviewed By: priteshrnandgaonkar

Differential Revision: D16828183

fbshipit-source-id: 720f7411d4327870c01d3f70e9d2b03909362795
This commit is contained in:
Pascal Hartig
2019-08-16 07:33:25 -07:00
committed by Facebook Github Bot
parent 6b93cd15c2
commit a76eddd16a
18 changed files with 355 additions and 94 deletions

View File

@@ -33,7 +33,7 @@ public class DestructorThread {
private Destructor next;
private Destructor previous;
Destructor(Object referent) {
public Destructor(Object referent) {
super(referent, sReferenceQueue);
sDestructorStack.push(this);
}
@@ -43,16 +43,16 @@ public class DestructorThread {
}
/** Callback which is invoked when the original object has been garbage collected. */
abstract void destruct();
protected abstract void destruct();
}
/** A list to keep all active Destructors in memory confined to the Destructor thread. */
private static DestructorList sDestructorList;
private static final DestructorList sDestructorList;
/** A thread safe stack where new Destructors are placed before being add to sDestructorList. */
private static DestructorStack sDestructorStack;
private static final DestructorStack sDestructorStack;
private static ReferenceQueue sReferenceQueue;
private static Thread sThread;
private static final ReferenceQueue sReferenceQueue;
private static final Thread sThread;
static {
sDestructorStack = new DestructorStack();
@@ -86,14 +86,14 @@ public class DestructorThread {
private static class Terminus extends Destructor {
@Override
void destruct() {
protected void destruct() {
throw new IllegalStateException("Cannot destroy Terminus Destructor.");
}
}
/** This is a thread safe, lock-free Treiber-like Stack of Destructors. */
private static class DestructorStack {
private AtomicReference<Destructor> mHead = new AtomicReference<>();
private final AtomicReference<Destructor> mHead = new AtomicReference<>();
public void push(Destructor newHead) {
Destructor oldHead;
@@ -115,7 +115,7 @@ public class DestructorThread {
/** A doubly-linked list of Destructors. */
private static class DestructorList {
private Destructor mHead;
private final Destructor mHead;
public DestructorList() {
mHead = new Terminus();

View File

@@ -65,7 +65,7 @@ public class HybridData {
}
@Override
void destruct() {
protected final void destruct() {
// When invoked from the DestructorThread instead of resetNative,
// the DestructorThread has exclusive ownership of the HybridData
// so synchronization is not necessary.