Changeset 27717 in webkit


Ignore:
Timestamp:
Nov 12, 2007 10:34:45 AM (16 years ago)
Author:
mrowe@apple.com
Message:

2007-11-12 Justin Haygood <jhaygood@reaktix.com>

Reviewed by Brady.

http://bugs.webkit.org/show_bug.cgi?id=15955
Reimplement threading functions in IconDatabase and SQLiteDatabase in terms of the threading abstractions

  • loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::open): (WebCore::IconDatabase::close):
  • loader/icon/IconDatabase.h:
  • platform/sql/SQLiteDatabase.cpp: (WebCore::SQLiteDatabase::SQLiteDatabase): (WebCore::SQLiteDatabase::open): (WebCore::SQLiteDatabase::close):
  • platform/sql/SQLiteDatabase.h:
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r27716 r27717  
     12007-11-12  Justin Haygood  <jhaygood@reaktix.com>
     2
     3        Reviewed by Brady.
     4
     5        http://bugs.webkit.org/show_bug.cgi?id=15955
     6        Reimplement threading functions in IconDatabase and SQLiteDatabase in terms of the threading abstractions
     7
     8        * loader/icon/IconDatabase.cpp:
     9        (WebCore::IconDatabase::open):
     10        (WebCore::IconDatabase::close):
     11        * loader/icon/IconDatabase.h:
     12        * platform/sql/SQLiteDatabase.cpp:
     13        (WebCore::SQLiteDatabase::SQLiteDatabase):
     14        (WebCore::SQLiteDatabase::open):
     15        (WebCore::SQLiteDatabase::close):
     16        * platform/sql/SQLiteDatabase.h:
     17
    1182007-11-12  Adam Roben  <aroben@apple.com>
    219
  • trunk/WebCore/loader/icon/IconDatabase.cpp

    r27054 r27717  
    11/*
    22 * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
     3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    5051#endif
    5152
     53#if PLATFORM(DARWIN)
     54#include <pthread.h>
     55#endif
     56
    5257#include <errno.h>
    5358
     
    5661
    5762// For methods that are meant to support the sync thread ONLY
    58 #define IS_ICON_SYNC_THREAD() pthread_equal(pthread_self(), m_syncThread)
     63#define IS_ICON_SYNC_THREAD() m_syncThread == currentThread()
    5964#define ASSERT_ICON_SYNC_THREAD() ASSERT(IS_ICON_SYNC_THREAD())
    6065
     
    137142    m_completeDatabasePath = pathByAppendingComponent(m_databaseDirectory, defaultDatabaseFilename());
    138143
    139     // Lock here as well as first thing in the thread so the tread doesn't actually commence until the pthread_create() call
     144    // Lock here as well as first thing in the thread so the thread doesn't actually commence until the createThread() call
    140145    // completes and m_syncThreadRunning is properly set
    141146    m_syncLock.lock();
    142     m_syncThreadRunning = !pthread_create(&m_syncThread, NULL, IconDatabase::iconDatabaseSyncThreadStart, this);
    143     m_syncLock.unlock();
    144 
    145     return m_syncThreadRunning;
     147    m_syncThread = createThread(IconDatabase::iconDatabaseSyncThreadStart, this);
     148    if (!m_syncThread)
     149        return false;
     150    return true;
    146151}
    147152
     
    158163       
    159164        // Wait for the sync thread to terminate
    160         if (pthread_join(m_syncThread, NULL) == EDEADLK)
    161             LOG_ERROR("m_syncThread was found to be deadlocked trying to quit");
     165        waitForThreadCompletion(m_syncThread, 0);
    162166    }
    163167
  • trunk/WebCore/loader/icon/IconDatabase.h

    r27054 r27717  
    11/*
    22 * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
     3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    121122    void syncTimerFired(Timer<IconDatabase>*);
    122123   
    123     pthread_t m_syncThread;
     124    ThreadIdentifier m_syncThread;
    124125    bool m_syncThreadRunning;
    125126   
  • trunk/WebCore/platform/sql/SQLiteDatabase.cpp

    r27054 r27717  
    11/*
    22 * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
     3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    4546    : m_db(0)
    4647    , m_transactionInProgress(false)
    47 {
    48 #ifndef NDEBUG
    49     memset(&m_openingThread, 0, sizeof(pthread_t));
    50 #endif
     48    , m_openingThread(0)
     49{
    5150}
    5251
     
    7271    }
    7372
    74 #ifndef NDEBUG
    7573    if (isOpen())
    76         m_openingThread = pthread_self();
    77 #endif
     74        m_openingThread = currentThread();
    7875   
    7976    if (!SQLiteStatement(*this, "PRAGMA temp_store = MEMORY;").executeCommand())
     
    9087        m_db = 0;
    9188    }
    92 #ifndef NDEBUG
    93     memset(&m_openingThread, 0, sizeof(pthread_t));
    94 #endif
     89
     90    m_openingThread = 0;
    9591}
    9692
     
    297293
    298294} // namespace WebCore
    299 
    300 
  • trunk/WebCore/platform/sql/SQLiteDatabase.h

    r27054 r27717  
    11/*
    22 * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
     3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3132#include <wtf/Noncopyable.h>
    3233#include <wtf/Vector.h>
    33 
    34 #ifndef NDEBUG
    35 #include <pthread.h>
    36 #endif
    3734
    3835#if COMPILER(MSVC)
     
    9895   
    9996    sqlite3* sqlite3Handle() const {
    100         ASSERT(pthread_equal(m_openingThread, pthread_self()));
     97        ASSERT(currentThread() == m_openingThread);
    10198        return m_db;
    10299    }
     
    120117
    121118    Mutex m_lockingMutex;
    122 #ifndef NDEBUG
    123     pthread_t m_openingThread;
    124 #endif
     119    ThreadIdentifier m_openingThread;
    125120   
    126121}; // class SQLiteDatabase
Note: See TracChangeset for help on using the changeset viewer.