Bug 15955

Summary: WebCore should use threading abstraction
Product: WebKit Reporter: Justin Haygood <jhaygood>
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.4   
Attachments:
Description Flags
Reimplements IconDatabase and SQLiteDatabase in terms of threading API
beidson: review-
Reimplements IconDatabase and SQLiteDatabase in terms of threading API
beidson: review-
Reimplements IconDatabase and SQLiteDatabase in terms of threading API beidson: review+

Description Justin Haygood 2007-11-12 08:54:15 PST
Some code still uses pthread directly. Now that we have this fancy threading abstraction API, we should use it everywhere.
Comment 1 Justin Haygood 2007-11-12 08:54:39 PST
Created attachment 17203 [details]
Reimplements IconDatabase and SQLiteDatabase in terms of threading API
Comment 2 Brady Eidson 2007-11-12 09:34:28 PST
Comment on attachment 17203 [details]
Reimplements IconDatabase and SQLiteDatabase in terms of threading API

I wanted to get to this ever since we first landed the abstraction - thanks for taking it on!
I have a few nitpicks:

> createThread( IconDatabase::iconDatabaseSyncThreadStart, this );  
No space inside the parens.  Occurs in a few places.

> if(!m_syncThread)
Space after the if.

> -#if PLATFORM(DARWIN)
> -    ASSERT(pthread_main_np());
> -#endif
This block of code is valuable, and I would like to see it eventually expanded to include all platforms.
The Threading abstraction doesn't yet support a "getMainThreadID()" so there's not (yet) a drop in replacement, so I'm a little torn on what to do with it now...  Since adding such an interface would be an exercise in adding platform specific code whereas this patch is an exercise in removing it!  
I think leaving this block for now (along with the pthread.h include for DARWIN only) and filing a bug with a FIXME would be sufficient.

> -#ifndef NDEBUG
> -    memset(&m_openingThread, 0, sizeof(pthread_t));
> -#endif
It might not be critically necessary since it's debug-only code, but I'd like to see the thread identifier zero'ed out in the initialization list in place of this code.
Comment 3 Justin Haygood 2007-11-12 09:52:32 PST
Created attachment 17206 [details]
Reimplements IconDatabase and SQLiteDatabase in terms of threading API

Updated threading stuff... basically puts back the assert and sets m_openingThread to 0
Comment 4 Brady Eidson 2007-11-12 09:57:17 PST
Comment on attachment 17206 [details]
Reimplements IconDatabase and SQLiteDatabase in terms of threading API

There's still the style-only tweaks I mentioned (re: parenthesis)

> #ifndef NDEBUG
>-    memset(&m_openingThread, 0, sizeof(pthread_t));
>+    m_openingThread = 0;
> #endif

Since it's just an integral type now and we set m_openingThread(0) in the initializer list, maybe we should just remove the #ifndef NDEBUG/#endif here.
Comment 5 Justin Haygood 2007-11-12 10:07:06 PST
Created attachment 17207 [details]
Reimplements IconDatabase and SQLiteDatabase in terms of threading API

Hopefully final review :)
Comment 6 Brady Eidson 2007-11-12 10:08:55 PST
Comment on attachment 17207 [details]
Reimplements IconDatabase and SQLiteDatabase in terms of threading API

Yay!  

There *is* still one style issue left -
if(!m_syncThread)
should be
if (!m_syncThread)

Otherwise looks great
Comment 7 Mark Rowe (bdash) 2007-11-12 10:35:27 PST
Landed in r27717 with coding style tweaks.