Closed
Bug 112397
Opened 23 years ago
Closed 23 years ago
Add IsMainThread to nsIThread
Categories
(Core :: XPCOM, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: dougt, Assigned: dougt)
Details
Attachments
(1 file)
1.07 KB,
patch
|
darin.moz
:
superreview+
|
Details | Diff | Splinter Review |
I need a cheap way to check if the current thread is the main thread. I added a
method nsIThread::IsMainThread. Check out the diffs.
Assignee | ||
Comment 1•23 years ago
|
||
This snatch of code is somewhat common throughout Mozilla:
nsCOMPtr<nsIThread> main;
nsCOMPtr<nsIThread> current;
nsIThread::GetMainThread(getter_AddRefs(main));
nsIThread::GetCurrent(getter_AddRefs(current));
if (main == current) ...
Too much hassle? Nnnh. I guess this new method won't hurt anything. I find its
name confusing, though, since the method has nothing to do with any nsIThread
object you may be holding onto. How about calling it CurrentThreadIsMainThread,
and r=danm.
Assignee | ||
Comment 3•23 years ago
|
||
The problem with the snippet you suggested is:
1) two atomic sets for the addref'ing
2) GetThread() can create a nsIThread for the current thread.
This routine just makes things faster.
CurrentThreadIsMainThread is a bit wordy. Isn't CurrentThread implied but the
function call itself. I don't care either way, i guess.
Thanks for the review.
Comment 4•23 years ago
|
||
i prefer nsIThread::IsMainThread over nsIThread::CurrentThreadIsMainThread
Comment 5•23 years ago
|
||
Comment on attachment 59523 [details] [diff] [review]
Adds nsIThread::IsMainThread
sr=darin
Attachment #59523 -
Flags: superreview+
Assignee | ||
Comment 6•23 years ago
|
||
Checking in nsThread.cpp;
/cvsroot/mozilla/xpcom/threads/nsThread.cpp,v <-- nsThread.cpp
new revision: 1.40; previous revision: 1.39
done
Checking in nsIThread.idl;
/cvsroot/mozilla/xpcom/threads/nsIThread.idl,v <-- nsIThread.idl
new revision: 1.7; previous revision: 1.6
done
Thanks
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•