Closed Bug 478304 Opened 16 years ago Closed 16 years ago

Let nsRunnableMethod be used with non-void-returning functions

Categories

(Core :: XPCOM, defect)

All
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bent.mozilla, Assigned: bent.mozilla)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch Patch, v1 (obsolete) — 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)
No longer depends on: 340345
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+
Attached patch Patch, v1.1Splinter Review
With those changes, ready for checkin.
Attachment #362148 - Attachment is obsolete: true
Attachment #362352 - Flags: review+
Pushed changeset c877b7e214a1 to mozilla-central.
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
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.

Attachment

General

Created:
Updated:
Size: