Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19666323 authored by Vasu Nori's avatar Vasu Nori
Browse files

remove unnecessary synchronization object from SQLiteClosable.

and a couple of other minor SMP fixes

Change-Id: I62bb4dd2fe43fc41074454a25bd84ad1fb4d004d
parent 35c8b532
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -23,13 +23,12 @@ import android.database.CursorWindow;
 */
public abstract class SQLiteClosable {
    private int mReferenceCount = 1;
    private Object mLock = new Object();

    protected abstract void onAllReferencesReleased();
    protected void onAllReferencesReleasedFromContainer() {}

    public void acquireReference() {
        synchronized(mLock) {
        synchronized(this) {
            checkRefCount();
            if (mReferenceCount <= 0) {
                throw new IllegalStateException(
@@ -40,7 +39,7 @@ public abstract class SQLiteClosable {
    }

    public void releaseReference() {
        synchronized(mLock) {
        synchronized(this) {
            checkRefCount();
            mReferenceCount--;
            if (mReferenceCount == 0) {
@@ -50,7 +49,7 @@ public abstract class SQLiteClosable {
    }

    public void releaseReferenceFromContainer() {
        synchronized(mLock) {
        synchronized(this) {
            checkRefCount();
            mReferenceCount--;
            if (mReferenceCount == 0) {
+5 −1
Original line number Diff line number Diff line
@@ -215,8 +215,8 @@ public abstract class SQLiteProgram extends SQLiteClosable {
    }

    private void bind(int type, int index, Object value) {
        mDatabase.verifyDbIsOpen();
        synchronized (this) {
            mDatabase.verifyDbIsOpen();
            addToBindArgs(index, (type == Cursor.FIELD_TYPE_NULL) ? null : value);
            if (nStatement > 0) {
                // bind only if the SQL statement is compiled
@@ -395,6 +395,10 @@ public abstract class SQLiteProgram extends SQLiteClosable {
        }
    }

    /* package */ synchronized final void setNativeHandle(int nHandle) {
        this.nHandle = nHandle;
    }

    /**
     * @deprecated This method is deprecated and must not be used.
     * Compiles SQL into a SQLite program.
+2 −2
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ public class SQLiteStatement extends SQLiteProgram
        // use the database connection obtained above
        mOrigDb = mDatabase;
        mDatabase = db;
        nHandle = mDatabase.mNativeHandle;
        setNativeHandle(mDatabase.mNativeHandle);
        if (rwFlag == WRITE) {
            BlockGuard.getThreadPolicy().onWriteToDisk();
        } else {
@@ -268,7 +268,7 @@ public class SQLiteStatement extends SQLiteProgram
        release();
        // restore the database connection handle to the original value
        mDatabase = mOrigDb;
        nHandle = mDatabase.mNativeHandle;
        setNativeHandle(mDatabase.mNativeHandle);
    }

    private final native int native_execute();