Debugger: Add host listener implementation.
TargetHostInterfaceRoster: - Implement TargetHostInterface's Listener interface. This allows us to more cheaply track the total number of running team debuggers, as well as automatically removing an interface that is destroyed.
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
#include <AutoLocker.h>
|
||||
|
||||
#include "LocalTargetHostInterfaceInfo.h"
|
||||
#include "TargetHostInterface.h"
|
||||
#include "TargetHostInterfaceInfo.h"
|
||||
|
||||
|
||||
@@ -20,7 +19,9 @@
|
||||
|
||||
TargetHostInterfaceRoster::TargetHostInterfaceRoster()
|
||||
:
|
||||
TargetHostInterface::Listener(),
|
||||
fLock(),
|
||||
fRunningTeamDebuggers(0),
|
||||
fInterfaceInfos(20, false),
|
||||
fActiveInterfaces(20, false)
|
||||
{
|
||||
@@ -136,6 +137,7 @@ TargetHostInterfaceRoster::CreateInterface(TargetHostInterfaceInfo* info,
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
interface->AddListener(this);
|
||||
_interface = interface;
|
||||
return B_OK;
|
||||
}
|
||||
@@ -155,14 +157,24 @@ TargetHostInterfaceRoster::ActiveInterfaceAt(int32 index) const
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
TargetHostInterfaceRoster::CountRunningTeamDebuggers() const
|
||||
void
|
||||
TargetHostInterfaceRoster::TeamDebuggerStarted(TeamDebugger* debugger)
|
||||
{
|
||||
int32 total = 0;
|
||||
for (int32 i = 0; TargetHostInterface* interface = ActiveInterfaceAt(i);
|
||||
i++) {
|
||||
total += interface->CountTeamDebuggers();
|
||||
}
|
||||
|
||||
return total;
|
||||
fRunningTeamDebuggers++;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TargetHostInterfaceRoster::TeamDebuggerQuit(TeamDebugger* debugger)
|
||||
{
|
||||
fRunningTeamDebuggers--;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TargetHostInterfaceRoster::TargetHostInterfaceQuit(
|
||||
TargetHostInterface* interface)
|
||||
{
|
||||
AutoLocker<TargetHostInterfaceRoster> locker(this);
|
||||
fActiveInterfaces.RemoveItem(interface);
|
||||
}
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
#include <Locker.h>
|
||||
#include <ObjectList.h>
|
||||
|
||||
#include "TargetHostInterface.h"
|
||||
|
||||
|
||||
class Settings;
|
||||
class TargetHostInterface;
|
||||
class TargetHostInterfaceInfo;
|
||||
|
||||
|
||||
class TargetHostInterfaceRoster {
|
||||
class TargetHostInterfaceRoster : private TargetHostInterface::Listener {
|
||||
public:
|
||||
TargetHostInterfaceRoster();
|
||||
virtual ~TargetHostInterfaceRoster();
|
||||
@@ -42,7 +43,14 @@ public:
|
||||
int32 CountActiveInterfaces() const;
|
||||
TargetHostInterface* ActiveInterfaceAt(int32 index) const;
|
||||
|
||||
int32 CountRunningTeamDebuggers() const;
|
||||
int32 CountRunningTeamDebuggers() const
|
||||
{ return fRunningTeamDebuggers; }
|
||||
|
||||
// TargetHostInterface::Listener
|
||||
virtual void TeamDebuggerStarted(TeamDebugger* debugger);
|
||||
virtual void TeamDebuggerQuit(TeamDebugger* debugger);
|
||||
virtual void TargetHostInterfaceQuit(
|
||||
TargetHostInterface* interface);
|
||||
|
||||
private:
|
||||
typedef BObjectList<TargetHostInterfaceInfo> InfoList;
|
||||
@@ -52,6 +60,7 @@ private:
|
||||
BLocker fLock;
|
||||
static TargetHostInterfaceRoster* sDefaultInstance;
|
||||
|
||||
int32 fRunningTeamDebuggers;
|
||||
InfoList fInterfaceInfos;
|
||||
InterfaceList fActiveInterfaces;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user