35 #include <nsIAppStartupNotifier.h>
36 #include <nsIObserverService.h>
38 #include <nsComponentManagerUtils.h>
40 #include <nsServiceManagerUtils.h>
50 static PRLogModuleInfo* gThreadPoolServiceLog = nsnull;
51 #define TRACE(args) PR_LOG(gThreadPoolServiceLog, PR_LOG_DEBUG, args)
52 #define LOG(args) PR_LOG(gThreadPoolServiceLog, PR_LOG_WARN, args)
58 #define DEFAULT_THREAD_LIMIT (8)
59 #define DEFAULT_IDLE_LIMIT (1)
60 #define DEFAULT_IDLE_TIMEOUT (10000)
62 #define NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID "xpcom-shutdown-threads"
72 if (!gThreadPoolServiceLog) {
73 gThreadPoolServiceLog = PR_NewLogModule(
"sbThreadPoolService");
76 TRACE((
"sbThreadPoolService[0x%x] - ctor",
this));
82 TRACE((
"sbThreadPoolService[0x%x] - dtor",
this));
88 nsresult rv = NS_ERROR_UNEXPECTED;
89 mThreadPool = do_CreateInstance(
"@mozilla.org/thread-pool;1", &rv);
90 NS_ENSURE_SUCCESS(rv, rv);
93 NS_ENSURE_SUCCESS(rv, rv);
96 NS_ENSURE_SUCCESS(rv, rv);
99 NS_ENSURE_SUCCESS(rv, rv);
106 sbThreadPoolService::Observe(
nsISupports *aSubject,
108 const PRUnichar *
aData)
110 LOG((
"sbThreadPoolService[0x%x] - Observe (%s)",
this, aTopic));
112 nsresult rv = NS_ERROR_UNEXPECTED;
114 if (!strcmp(aTopic, NS_XPCOM_STARTUP_OBSERVER_ID)) {
115 nsresult rv = NS_ERROR_UNEXPECTED;
117 nsCOMPtr<nsIObserverService> obsSvc =
118 do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
119 NS_ENSURE_SUCCESS(rv, rv);
122 do_QueryInterface(NS_ISUPPORTS_CAST(
nsIObserver*,
this), &rv);
123 NS_ENSURE_SUCCESS(rv, rv);
126 NS_ENSURE_SUCCESS(rv, rv);
129 nsCOMPtr<nsIObserverService> obsSvc =
130 do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
131 NS_ENSURE_SUCCESS(rv, rv);
133 nsCOMPtr<nsIObserver> observer =
134 do_QueryInterface(NS_ISUPPORTS_CAST(
nsIObserver*,
this), &rv);
135 NS_ENSURE_SUCCESS(rv, rv);
138 NS_ENSURE_SUCCESS(rv, rv);
142 nsresult rv = mThreadPool->Shutdown();
143 NS_ENSURE_SUCCESS(rv, rv);
#define DEFAULT_IDLE_LIMIT
NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER nsresult Init()
#define DEFAULT_THREAD_LIMIT
NS_IMPL_THREADSAFE_ISUPPORTS3(sbThreadPoolService, nsIEventTarget, nsIThreadPool, nsIObserver) sbThreadPoolService
virtual ~sbThreadPoolService()
Songbird Thread Pool Service.
#define NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID
#define DEFAULT_IDLE_TIMEOUT
_updateTextAndScrollDataForFrame aData