registrar: Replace the deprecated std::hash_set with our HashSet.

This commit is contained in:
Augustin Cavalier 2020-03-07 22:10:50 -05:00
parent 5c31a5242c
commit c207330527
4 changed files with 23 additions and 29 deletions

View File

@ -860,11 +860,11 @@ ShutdownProcess::MessageReceived(BMessage* message)
if (open) {
PRINT("B_REG_TEAM_DEBUGGER_ALERT: insert %" B_PRId32 "\n",
team);
fDebuggedTeams.insert(team);
fDebuggedTeams.Add(team);
} else {
PRINT("B_REG_TEAM_DEBUGGER_ALERT: remove %" B_PRId32 "\n",
team);
fDebuggedTeams.erase(team);
fDebuggedTeams.Remove(team);
_PushEvent(DEBUG_EVENT, -1, fCurrentPhase);
}
break;
@ -1670,7 +1670,7 @@ ShutdownProcess::_QuitNonApps()
int32 cookie = 0;
team_info teamInfo;
while (get_next_team_info(&cookie, &teamInfo) == B_OK) {
if (fVitalSystemApps.find(teamInfo.team) == fVitalSystemApps.end()) {
if (!fVitalSystemApps.Contains(teamInfo.team)) {
PRINT(" sending team %" B_PRId32 " TERM signal\n", teamInfo.team);
// Note: team ID == team main thread ID under Haiku
@ -1686,7 +1686,7 @@ ShutdownProcess::_QuitNonApps()
// iterate through the remaining teams and kill them
cookie = 0;
while (get_next_team_info(&cookie, &teamInfo) == B_OK) {
if (fVitalSystemApps.find(teamInfo.team) == fVitalSystemApps.end()) {
if (!fVitalSystemApps.Contains(teamInfo.team)) {
PRINT(" killing team %" B_PRId32 "\n", teamInfo.team);
kill_team(teamInfo.team);
@ -1705,7 +1705,7 @@ ShutdownProcess::_QuitBlockingApp(AppInfoList& list, team_id team,
bool modal = false;
{
BAutolock _(fWorkerLock);
if (fDebuggedTeams.find(team) != fDebuggedTeams.end())
if (fDebuggedTeams.Contains(team))
debugged = true;
}
if (!debugged)
@ -1853,7 +1853,7 @@ ShutdownProcess::_WaitForDebuggedTeams()
PRINT("ShutdownProcess::_WaitForDebuggedTeams()\n");
{
BAutolock _(fWorkerLock);
if (fDebuggedTeams.empty())
if (fDebuggedTeams.Size() == 0)
return;
}
@ -1872,7 +1872,7 @@ ShutdownProcess::_WaitForDebuggedTeams()
throw_error(B_SHUTDOWN_CANCELLED);
BAutolock _(fWorkerLock);
if (fDebuggedTeams.empty()) {
if (fDebuggedTeams.Size() == 0) {
PRINT(" out empty");
return;
}

View File

@ -7,8 +7,8 @@
#ifndef SHUTDOWN_PROCESS_H
#define SHUTDOWN_PROCESS_H
#include <hash_set>
#include <HashMap.h>
#include <HashSet.h>
#include <Locker.h>
#include <Looper.h>
@ -16,11 +16,6 @@
#include "EventMaskWatcher.h"
#include "RosterAppInfo.h"
#if __GNUC__ >= 4
using __gnu_cxx::hash_set;
#endif
class EventQueue;
class TRoster;
@ -95,6 +90,8 @@ private:
class QuitRequestReplyHandler;
class ShutdownWindow;
typedef HashSet<HashKey32<team_id> > TeamHash;
friend class QuitRequestReplyHandler;
BLocker fWorkerLock;
@ -103,11 +100,11 @@ private:
BMessage* fRequest;
TRoster* fRoster;
EventQueue* fEventQueue;
hash_set<team_id> fVitalSystemApps;
TeamHash fVitalSystemApps;
AppInfoList fSystemApps;
AppInfoList fUserApps;
AppInfoList fBackgroundApps;
hash_set<team_id> fDebuggedTeams;
TeamHash fDebuggedTeams;
TimeoutEvent* fTimeoutEvent;
InternalEventList* fInternalEvents;
sem_id fInternalEventSemaphore;

View File

@ -1404,7 +1404,7 @@ TRoster::SetShuttingDown(bool shuttingDown)
*/
status_t
TRoster::GetShutdownApps(AppInfoList& userApps, AppInfoList& systemApps,
AppInfoList& backgroundApps, hash_set<team_id>& vitalSystemApps)
AppInfoList& backgroundApps, HashSet<HashKey32<team_id> >& vitalSystemApps)
{
BAutolock _(fLock);
@ -1417,28 +1417,28 @@ TRoster::GetShutdownApps(AppInfoList& userApps, AppInfoList& systemApps,
// * debug server
// ourself
vitalSystemApps.insert(be_app->Team());
vitalSystemApps.Add(be_app->Team());
// kernel team
team_info teamInfo;
if (get_team_info(B_SYSTEM_TEAM, &teamInfo) == B_OK)
vitalSystemApps.insert(teamInfo.team);
vitalSystemApps.Add(teamInfo.team);
// app server
RosterAppInfo* info
= fRegisteredApps.InfoFor("application/x-vnd.haiku-app_server");
if (info != NULL)
vitalSystemApps.insert(info->team);
vitalSystemApps.Add(info->team);
// debug server
info = fRegisteredApps.InfoFor("application/x-vnd.haiku-debug_server");
if (info != NULL)
vitalSystemApps.insert(info->team);
vitalSystemApps.Add(info->team);
// populate the other groups
for (AppInfoList::Iterator it(fRegisteredApps.It());
RosterAppInfo* info = *it; ++it) {
if (vitalSystemApps.find(info->team) == vitalSystemApps.end()) {
if (!vitalSystemApps.Contains(info->team)) {
RosterAppInfo* clonedInfo = info->Clone();
if (clonedInfo) {
if (_IsSystemApp(info)) {
@ -1466,7 +1466,7 @@ TRoster::GetShutdownApps(AppInfoList& userApps, AppInfoList& systemApps,
// not excluded in the lists above
info = fRegisteredApps.InfoFor("application/x-vnd.Be-input_server");
if (info != NULL)
vitalSystemApps.insert(info->team);
vitalSystemApps.Add(info->team);
// clean up on error
if (error != B_OK) {

View File

@ -11,20 +11,17 @@
#include "RecentEntries.h"
#include "WatchingService.h"
#include <HashSet.h>
#include <HashMap.h>
#include <Locker.h>
#include <MessageQueue.h>
#include <Path.h>
#include <Roster.h>
#include <SupportDefs.h>
#include <hash_set>
#include <map>
#if __GNUC__ >= 4
using __gnu_cxx::hash_set;
#endif
using std::map;
class BMessage;
@ -77,7 +74,7 @@ public:
status_t GetShutdownApps(AppInfoList& userApps,
AppInfoList& systemApps,
AppInfoList& backgroundApps,
hash_set<team_id>& vitalSystemApps);
HashSet<HashKey32<team_id> >& vitalSystemApps);
status_t AddAppInfo(AppInfoList& apps, team_id team);
status_t AddWatcher(Watcher* watcher);