HaikuDepot: Remove Custom List
Further removal of the use of custom list class; this time with the package action lists. Also resolve an error created by a last minute change in the last pull request for this ticket. Relates To #15534 Change-Id: I85dd40b7ef664f93b24ca5041fa58cca17d72299 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3735 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
d75b4d610d
commit
6f07fead0c
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
|
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
* Copyright 2013, Rene Gollent, <rene@gollent.com>
|
* Copyright 2013, Rene Gollent, <rene@gollent.com>
|
||||||
|
* Copyright 2021, Andrew Lindesay <apl@lindesay.co.nz>
|
||||||
*
|
*
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@ -64,7 +65,6 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
typedef BReference<PackageAction> PackageActionRef;
|
typedef BReference<PackageAction> PackageActionRef;
|
||||||
typedef List<PackageActionRef, false> PackageActionList;
|
|
||||||
|
|
||||||
|
|
||||||
#endif // PACKAGE_ACTION_H
|
#endif // PACKAGE_ACTION_H
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013, Rene Gollent <rene@gollent.com>.
|
* Copyright 2013, Rene Gollent <rene@gollent.com>.
|
||||||
|
* Copyright 2021, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -19,8 +20,8 @@ class PackageActionHandler {
|
|||||||
public:
|
public:
|
||||||
virtual ~PackageActionHandler();
|
virtual ~PackageActionHandler();
|
||||||
|
|
||||||
virtual status_t SchedulePackageActions(
|
virtual status_t SchedulePackageAction(
|
||||||
PackageActionList& list) = 0;
|
PackageActionRef action) = 0;
|
||||||
|
|
||||||
virtual Model* GetModel() = 0;
|
virtual Model* GetModel() = 0;
|
||||||
};
|
};
|
||||||
|
@ -429,7 +429,7 @@ MainWindow::MessageReceived(BMessage* message)
|
|||||||
BAutolock locker(fModel.Lock());
|
BAutolock locker(fModel.Lock());
|
||||||
package = fModel.PackageForName(name);
|
package = fModel.PackageForName(name);
|
||||||
}
|
}
|
||||||
if (package.IsSet() || name != package->Name())
|
if (!package.IsSet() || name != package->Name())
|
||||||
debugger("unable to find the named package");
|
debugger("unable to find the named package");
|
||||||
else
|
else
|
||||||
_AdoptPackage(package);
|
_AdoptPackage(package);
|
||||||
@ -605,15 +605,11 @@ MainWindow::PackageChanged(const PackageInfoEvent& event)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MainWindow::SchedulePackageActions(PackageActionList& list)
|
MainWindow::SchedulePackageAction(PackageActionRef action)
|
||||||
{
|
{
|
||||||
AutoLocker<BLocker> lock(&fPendingActionsLock);
|
AutoLocker<BLocker> lock(&fPendingActionsLock);
|
||||||
for (int32 i = 0; i < list.CountItems(); i++) {
|
fPendingActions.push(action);
|
||||||
if (!fPendingActions.Add(list.ItemAtFast(i)))
|
return release_sem_etc(fPendingActionsSem, 1, 0);
|
||||||
return B_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
return release_sem_etc(fPendingActionsSem, list.CountItems(), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -989,7 +985,7 @@ MainWindow::_HandleWorkStatusChangeMessageReceived(const BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
/*static*/ status_t
|
||||||
MainWindow::_PackageActionWorker(void* arg)
|
MainWindow::_PackageActionWorker(void* arg)
|
||||||
{
|
{
|
||||||
MainWindow* window = reinterpret_cast<MainWindow*>(arg);
|
MainWindow* window = reinterpret_cast<MainWindow*>(arg);
|
||||||
@ -998,10 +994,10 @@ MainWindow::_PackageActionWorker(void* arg)
|
|||||||
PackageActionRef ref;
|
PackageActionRef ref;
|
||||||
{
|
{
|
||||||
AutoLocker<BLocker> lock(&window->fPendingActionsLock);
|
AutoLocker<BLocker> lock(&window->fPendingActionsLock);
|
||||||
ref = window->fPendingActions.ItemAt(0);
|
ref = window->fPendingActions.front();
|
||||||
|
window->fPendingActions.pop();
|
||||||
if (!ref.IsSet())
|
if (!ref.IsSet())
|
||||||
break;
|
break;
|
||||||
window->fPendingActions.Remove(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BMessenger messenger(window);
|
BMessenger messenger(window);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
* Copyright 2013, Rene Gollent <rene@gollent.com>.
|
* Copyright 2013, Rene Gollent <rene@gollent.com>.
|
||||||
* Copyright 2017, Julian Harnath <julian.harnath@rwth-aachen.de>.
|
* Copyright 2017, Julian Harnath <julian.harnath@rwth-aachen.de>.
|
||||||
* Copyright 2017-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2017-2021, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef MAIN_WINDOW_H
|
#ifndef MAIN_WINDOW_H
|
||||||
@ -66,8 +66,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// PackageActionHandler
|
// PackageActionHandler
|
||||||
virtual status_t SchedulePackageActions(
|
virtual status_t SchedulePackageAction(PackageActionRef action);
|
||||||
PackageActionList& list);
|
|
||||||
virtual Model* GetModel();
|
virtual Model* GetModel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -168,7 +167,8 @@ private:
|
|||||||
bool fSinglePackageMode;
|
bool fSinglePackageMode;
|
||||||
|
|
||||||
thread_id fPendingActionsWorker;
|
thread_id fPendingActionsWorker;
|
||||||
PackageActionList fPendingActions;
|
std::queue<PackageActionRef>
|
||||||
|
fPendingActions;
|
||||||
BLocker fPendingActionsLock;
|
BLocker fPendingActionsLock;
|
||||||
sem_id fPendingActionsSem;
|
sem_id fPendingActionsSem;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
* Copyright 2018-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2018-2021, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -638,10 +638,7 @@ private:
|
|||||||
if (!action.IsSet())
|
if (!action.IsSet())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PackageActionList actions;
|
status_t result = fPackageActionHandler->SchedulePackageAction(action);
|
||||||
actions.Add(action);
|
|
||||||
status_t result
|
|
||||||
= fPackageActionHandler->SchedulePackageActions(actions);
|
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
HDERROR("Failed to schedule action: %s '%s': %s",
|
HDERROR("Failed to schedule action: %s '%s': %s",
|
||||||
|
Loading…
Reference in New Issue
Block a user