272
edits
| Line 168: | Line 168: | ||
}; | }; | ||
== | == Utilities == | ||
nsThreadUtils.h defines the following helper functions: | nsThreadUtils.h defines the following helper functions: | ||
| Line 186: | Line 186: | ||
PRBool | PRBool | ||
NS_IsMainThread(); | NS_IsMainThread(); | ||
The following nsCOMPtr helpers are defined to simplify things further: | |||
already_AddRefed<nsIThread> | |||
do_GetCurrentThread(); | |||
| |||
already_AddRefed<nsIThread> | |||
do_GetMainThread() | |||
| |||
already_AddRefed<nsIThread> | |||
do_GetThread(const nsACString &name) | |||
The class <code>nsRunnable</code> is also defined to simplify the | |||
implementation of new event types. For example, to define a new | |||
event all you need to do is write code like this: | |||
class MyEvent : public nsRunnable { | |||
public: | |||
MyEvent(... params ...); | |||
| |||
NS_IMETHOD Run() { | |||
// do stuff | |||
return NS_OK; | |||
} | |||
}; | |||
== Remarks == | == Remarks == | ||
edits