HaikuDepot: Move worker thread init into method

... and call it from the second version of the MainWindow constructor.
This commit is contained in:
Stephan Aßmus 2014-10-12 23:18:58 +02:00
parent 027e51ae7d
commit 639756547d
2 changed files with 26 additions and 16 deletions

View File

@ -165,21 +165,7 @@ MainWindow::MainWindow(BRect frame, const BMessage& settings)
_StartRefreshWorker();
fPendingActionsSem = create_sem(0, "PendingPackageActions");
if (fPendingActionsSem >= 0) {
fPendingActionsWorker = spawn_thread(&_PackageActionWorker,
"Planet Express", B_NORMAL_PRIORITY, this);
if (fPendingActionsWorker >= 0)
resume_thread(fPendingActionsWorker);
}
fPackageToPopulateSem = create_sem(0, "PopulatePackage");
if (fPackageToPopulateSem >= 0) {
fPopulatePackageWorker = spawn_thread(&_PopulatePackageWorker,
"Package Populator", B_NORMAL_PRIORITY, this);
if (fPopulatePackageWorker >= 0)
resume_thread(fPopulatePackageWorker);
}
_InitWorkerThreads();
}
@ -214,6 +200,8 @@ MainWindow::MainWindow(BRect frame, const BMessage& settings,
}
fPackageInfoView->SetPackage(package);
_InitWorkerThreads();
}
@ -497,6 +485,27 @@ MainWindow::_BuildMenu(BMenuBar* menuBar)
}
void
MainWindow::_InitWorkerThreads()
{
fPendingActionsSem = create_sem(0, "PendingPackageActions");
if (fPendingActionsSem >= 0) {
fPendingActionsWorker = spawn_thread(&_PackageActionWorker,
"Planet Express", B_NORMAL_PRIORITY, this);
if (fPendingActionsWorker >= 0)
resume_thread(fPendingActionsWorker);
}
fPackageToPopulateSem = create_sem(0, "PopulatePackage");
if (fPackageToPopulateSem >= 0) {
fPopulatePackageWorker = spawn_thread(&_PopulatePackageWorker,
"Package Populator", B_NORMAL_PRIORITY, this);
if (fPopulatePackageWorker >= 0)
resume_thread(fPopulatePackageWorker);
}
}
void
MainWindow::_AdoptModel()
{
@ -899,7 +908,7 @@ MainWindow::_PopulatePackageWorker(void* arg)
void
MainWindow::_NotifyUser(const char* title, const char* message)
{
BAlert *alert = new(std::nothrow) BAlert(title, message,
BAlert* alert = new(std::nothrow) BAlert(title, message,
B_TRANSLATE("Close"));
if (alert != NULL)

View File

@ -55,6 +55,7 @@ private:
private:
void _BuildMenu(BMenuBar* menuBar);
void _InitWorkerThreads();
void _AdoptModel();
void _AdoptPackage(const PackageInfoRef& package);