EventHandlerStatsFile(uint32_t id) : EventHandlerFile(id) {}
// These are events that we're not interested in saving in stats event files.
- virtual void handle(Start& event) {}
- virtual void handle(End& event) {}
+ virtual void Handle(Start& event) {}
+ virtual void Handle(End& event) {}
};
static EventManager* FromHandle(HANDLE hThreadContext)
if (pManager && pHandler)
{
- pManager->attach(pHandler);
+ pManager->Attach(pHandler);
return pManager;
}
}
// Dispatch event for this thread.
- void dispatch(HANDLE hThreadContext, Event& event)
+ void Dispatch(HANDLE hThreadContext, Event& event)
{
EventManager* pManager = FromHandle(hThreadContext);
SWR_ASSERT(pManager != nullptr);
- pManager->dispatch(event);
+ pManager->Dispatch(event);
}
}
void DestroyThreadContext(HANDLE hThreadContext);
// Dispatch event for this thread.
- void dispatch(HANDLE hThreadContext, Event& event);
+ void Dispatch(HANDLE hThreadContext, Event& event);
};
class EventManager
{
public:
- void attach(EventHandler* pHandler)
+ EventManager() {}
+
+ ~EventManager()
+ {
+ // Event manager owns destroying handler objects once attached.
+ ///@note See comment for Detach.
+ for (auto pHandler : mHandlers)
+ {
+ delete pHandler;
+ }
+ }
+
+ void Attach(EventHandler* pHandler)
{
mHandlers.push_back(pHandler);
}
- void dispatch(Event& event)
+ void Dispatch(Event& event)
{
///@todo Add event filter check here.
for (auto pHandler : mHandlers)
{
- event.accept(pHandler);
+ event.Accept(pHandler);
}
}
private:
// Handlers stay registered for life
- void detach(EventHandler* pHandler) { SWR_ASSERT(0); }
+ void Detach(EventHandler* pHandler) { SWR_ASSERT(0); }
std::vector<EventHandler*> mHandlers;
};
}
delete[] pContext->ppScratch;
- delete[] pContext->pArContext;
delete[] pContext->pStats;
delete(pContext->pHotTileMgr);
#define AR_API_CTX pContext->pArContext[pContext->NumWorkerThreads]
#ifdef KNOB_ENABLE_AR
- #define _AR_BEGIN(ctx, type, id) ArchRast::dispatch(ctx, ArchRast::Start(ArchRast::type, id))
- #define _AR_END(ctx, type, count) ArchRast::dispatch(ctx, ArchRast::End(ArchRast::type, count))
- #define _AR_EVENT(ctx, event) ArchRast::dispatch(ctx, ArchRast::event)
+ #define _AR_BEGIN(ctx, type, id) ArchRast::Dispatch(ctx, ArchRast::Start(ArchRast::type, id))
+ #define _AR_END(ctx, type, count) ArchRast::Dispatch(ctx, ArchRast::End(ArchRast::type, count))
+ #define _AR_EVENT(ctx, event) ArchRast::Dispatch(ctx, ArchRast::event)
#else
#ifdef KNOB_ENABLE_RDTSC
#define _AR_BEGIN(ctx, type, id) (void)ctx; RDTSC_START(type)
using namespace ArchRast;
% for name in protos['event_names']:
-void ${name}::accept(EventHandler* pHandler)
+void ${name}::Accept(EventHandler* pHandler)
{
- pHandler->handle(*this);
+ pHandler->Handle(*this);
}
% endfor
//////////////////////////////////////////////////////////////////////////
struct Event
{
- virtual void accept(EventHandler* pHandler) = 0;
+ Event() {}
+ virtual ~Event() {}
+
+ virtual void Accept(EventHandler* pHandler) = 0;
};
% for name in protos['event_names']:
% endfor
}
- virtual void accept(EventHandler* pHandler);
+ virtual void Accept(EventHandler* pHandler);
};
% endfor
}
\ No newline at end of file
class EventHandler
{
public:
+ EventHandler() {}
+ virtual ~EventHandler() {}
+
% for name in protos['event_names']:
- virtual void handle(${name}& event) {}
+ virtual void Handle(${name}& event) {}
% endfor
};
}
#endif
}
- ~EventHandlerFile()
+ virtual ~EventHandlerFile()
{
if (mFile.is_open()) mFile.close();
}
- void write(uint32_t eventId, const char* pBlock, uint32_t size)
+ void Write(uint32_t eventId, const char* pBlock, uint32_t size)
{
if (!mFile.is_open())
{
}
% for name in protos['event_names']:
- virtual void handle(${name}& event)
+ virtual void Handle(${name}& event)
{
% if protos['events'][name]['num_fields'] == 0:
- write(${protos['events'][name]['event_id']}, (char*)&event.data, 0);
+ Write(${protos['events'][name]['event_id']}, (char*)&event.data, 0);
% else:
- write(${protos['events'][name]['event_id']}, (char*)&event.data, sizeof(event.data));
+ Write(${protos['events'][name]['event_id']}, (char*)&event.data, sizeof(event.data));
%endif
}
% endfor