Closed
Bug 478304
Opened 16 years ago
Closed 16 years ago
Let nsRunnableMethod be used with non-void-returning functions
Categories
(Core :: XPCOM, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: bent.mozilla, Assigned: bent.mozilla)
Details
Attachments
(1 file, 1 obsolete file)
6.83 KB,
patch
|
bent.mozilla
:
review+
|
Details | Diff | Splinter Review |
nsRunnableMethod's restriction on void callback functions is unnecessary and there are lots of functions that return nsresults. Patch attached lets us use nsRunnableMethod with functions that return just about anything (besides already_AddRefed). Also lets us remove a runnable class added in bug 340345.
Attachment #362148 -
Flags: review?(benjamin)
Comment 1•16 years ago
|
||
Comment on attachment 362148 [details] [diff] [review]
Patch, v1
>diff --git a/xpcom/glue/nsThreadUtils.h b/xpcom/glue/nsThreadUtils.h
> NS_IMETHOD Run() {
>+ // Make sure this return type is safe.
>+ ReturnTypeEnforcer<ReturnType>::ReturnTypeIsSafeForRunnableMethod();
There's no need for this to be an actual method call. Just make it a static typename, at class scope:
typedef typename ReturnTypeEnforcer<ReturnType>::ReturnTypeIsSafe returntypecheck;
>+ // These ReturnTypeEnforcer classes set up a blacklist for return types that
>+ // we know are not safe. The default ReturnTypeEnforcer compiles just fine but
>+ // already_AddRefed will not.
>+ template <typename OtherReturnType>
>+ class ReturnTypeEnforcer
>+ {
>+ public:
>+ static void ReturnTypeIsSafeForRunnableMethod() { }
and then
typedef int ReturnTypeIsSafe;
Attachment #362148 -
Flags: review?(benjamin) → review+
Assignee | ||
Comment 2•16 years ago
|
||
With those changes, ready for checkin.
Attachment #362148 -
Attachment is obsolete: true
Attachment #362352 -
Flags: review+
Assignee | ||
Comment 3•16 years ago
|
||
Pushed changeset c877b7e214a1 to mozilla-central.
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Comment 4•16 years ago
|
||
Awesome, I've been wanting this for a while. Christmas in February!
You need to log in
before you can comment on or make changes to this bug.
Description
•