Bug 751423 - Wait for IO thread to finish setup. r=cjones

This commit is contained in:
Steven Lee 2012-05-04 15:16:27 +08:00
Родитель 277cb3e8cb
Коммит ddb77225b4
1 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -9,6 +9,7 @@
#include "base/message_loop.h"
#include "Hal.h"
#include "mozilla/Monitor.h"
#include "nsXULAppAPI.h"
#include "UeventPoller.h"
@ -154,18 +155,27 @@ ReleaseResourceIfNeed()
}
static void
EnableSwitchNotificationsIOThread(SwitchDevice aDevice)
EnableSwitchNotificationsIOThread(SwitchDevice aDevice, Monitor *aMonitor)
{
InitializeResourceIfNeed();
sSwitchObserver->EnableSwitch(aDevice);
{
MonitorAutoLock lock(*aMonitor);
lock.Notify();
}
}
void
EnableSwitchNotifications(SwitchDevice aDevice)
{
XRE_GetIOMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(EnableSwitchNotificationsIOThread, aDevice));
Monitor monitor("EnableSwitch.monitor");
{
MonitorAutoLock lock(monitor);
XRE_GetIOMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(EnableSwitchNotificationsIOThread, aDevice, &monitor));
lock.Wait();
}
}
static void