Skip to content

Commit

Permalink
Debugger: Add host listener implementation.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anevilyak committed Apr 21, 2016
1 parent 5bb138f commit 8527cd4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
Expand Up @@ -10,7 +10,6 @@
#include <AutoLocker.h>

#include "LocalTargetHostInterfaceInfo.h"
#include "TargetHostInterface.h"
#include "TargetHostInterfaceInfo.h"


Expand All @@ -20,7 +19,9 @@

TargetHostInterfaceRoster::TargetHostInterfaceRoster()
:
TargetHostInterface::Listener(),
fLock(),
fRunningTeamDebuggers(0),
fInterfaceInfos(20, false),
fActiveInterfaces(20, false)
{
Expand Down Expand Up @@ -136,6 +137,7 @@ TargetHostInterfaceRoster::CreateInterface(TargetHostInterfaceInfo* info,
return B_NO_MEMORY;
}

interface->AddListener(this);
_interface = interface;
return B_OK;
}
Expand All @@ -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();
}
fRunningTeamDebuggers++;
}


void
TargetHostInterfaceRoster::TeamDebuggerQuit(TeamDebugger* debugger)
{
fRunningTeamDebuggers--;
}


return total;
void
TargetHostInterfaceRoster::TargetHostInterfaceQuit(
TargetHostInterface* interface)
{
AutoLocker<TargetHostInterfaceRoster> locker(this);
fActiveInterfaces.RemoveItem(interface);
}
Expand Up @@ -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();
Expand All @@ -42,7 +43,14 @@ class TargetHostInterfaceRoster {
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;
Expand All @@ -52,6 +60,7 @@ class TargetHostInterfaceRoster {
BLocker fLock;
static TargetHostInterfaceRoster* sDefaultInstance;

int32 fRunningTeamDebuggers;
InfoList fInterfaceInfos;
InterfaceList fActiveInterfaces;
};
Expand Down

0 comments on commit 8527cd4

Please sign in to comment.