Skip to content

Commit

Permalink
Making sure a job in ServiceMap is properly Revoked (#1781)
Browse files Browse the repository at this point in the history
* Adding Revoke to ~ServiceMap, adding JobIdentifiers to all JobTypes in Thunder, fixing the macro

* Static assert is static, so no way to pass Identifier
  • Loading branch information
VeithMetro authored Oct 24, 2024
1 parent cbce328 commit d3a7a28
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Source/Thunder/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ namespace Plugin {
_parent.SubSystems();
}

string JobIdentifier() const {
return(_T("Thunder::Plugin::Controller::Sink::Job"));
}

private:
Controller& _parent;
};
Expand Down
20 changes: 18 additions & 2 deletions Source/Thunder/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,10 @@ namespace PluginHost {
return result;
}

string JobIdentifier() const {
return(_T("Thunder::PluginHost::Server::ServiceMap::CommunicatorServer"));
}

private:
ServiceMap& _parent;
const string _persistentPath;
Expand Down Expand Up @@ -2489,7 +2493,7 @@ namespace PluginHost {
_parent.Evaluate();
}
string JobIdentifier() const {
return(_T("PluginServer::SubSystems::Notification"));
return(_T("Thunder::PluginHost::Server::ServiceMap::SubSystems::Job"));
}

private:
Expand Down Expand Up @@ -2720,6 +2724,12 @@ namespace PluginHost {
POP_WARNING()
~ServiceMap()
{
Core::ProxyType<Core::IDispatch> job(_job.Revoke());

if (job.IsValid()) {
WorkerPool().Revoke(job);
_job.Revoked();
}
// Make sure all services are deactivated before we are killed (call Destroy on this object);
ASSERT(_services.size() == 0);
}
Expand Down Expand Up @@ -3429,6 +3439,11 @@ namespace PluginHost {
}

friend class Core::ThreadPool::JobType<ServiceMap&>;

string JobIdentifier() const {
return(_T("Thunder::PluginHost::Server::ServiceMap"));
}

void Dispatch()
{
_adminLock.Lock();
Expand Down Expand Up @@ -4525,8 +4540,9 @@ namespace PluginHost {
friend class Core::ThreadPool::JobType<ChannelMap&>;

string JobIdentifier() const {
return (_T("PluginServer::ChannelMap::Cleanup"));
return (_T("Thunder::PluginHost::Server::ChannelMap"));
}

void Dispatch()
{
TRACE(Activity, (string(_T("Cleanup job running..\n"))));
Expand Down
4 changes: 4 additions & 0 deletions Source/ThunderPlugin/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ POP_WARNING()
}
}

string JobIdentifier() const {
return(_T("Thunder::Process::WorkerPoolImplmenetation::Sink"));
}

private:
WorkerPoolImplementation& _parent;
Core::ThreadPool::JobType<Sink&> _job;
Expand Down
13 changes: 7 additions & 6 deletions Source/core/TypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "Portability.h"
#include <functional>
#include <type_traits>

namespace Thunder {

Expand Down Expand Up @@ -191,14 +192,14 @@ namespace Core {
// Args: arguments that func should have, note it will also work if overrides of Func are available on T. Note: passing Args&&... itself is also allowed here to allow for variable parameters
#define IS_MEMBER_AVAILABLE_INHERITANCE_TREE(func, name) \
template <bool, typename TT> \
struct name##_IsMemberAvailableCheck : public TT { \
using type = TT; \
struct name##_IsMemberAvailableCheck : public std::remove_reference<TT>::type { \
using type = typename std::remove_reference<TT>::type; \
template <typename TTT, typename... Args2> \
auto Verify() -> decltype( (TTT::func(std::declval<Args2>()...))); \
}; \
template <typename TT> \
struct name##_IsMemberAvailableCheck<true, TT> : public TT { \
using type = const TT; \
struct name##_IsMemberAvailableCheck<true, TT> : public std::remove_reference<TT>::type { \
using type = const typename std::remove_reference<TT>::type; \
template <typename TTT, typename... Args2> \
auto Verify() const -> decltype( (TTT::func(std::declval<Args2>()...))); \
}; \
Expand All @@ -207,12 +208,12 @@ namespace Core {
typedef char yes[1]; \
typedef char no[2]; \
template <typename U, \
typename RR = decltype(std::declval<name##_IsMemberAvailableCheck<std::is_const<U>::value, U>>().template Verify<U, Args...>()), \
typename RR = decltype(std::declval<name##_IsMemberAvailableCheck<std::is_const<typename std::remove_reference<U>::type>::value, U>>().template Verify<U, Args...>()), \
typename Z = typename std::enable_if<std::is_same<R, RR>::value>::type> \
static yes& chk(int); \
template <typename U> \
static no& chk(...); \
static bool const value = sizeof(chk<T>(0)) == sizeof(yes); \
static bool const value = sizeof(chk<typename std::remove_reference<T>::type>(0)) == sizeof(yes); \
}


Expand Down
4 changes: 4 additions & 0 deletions Source/extensions/bluetooth/audio/AVDTPSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ namespace AVDTP {
}
~Socket() = default;

string JobIdentifier() const {
return(_T("Thunder::Bluetooth::AVDTP::Socket"));
}

public:
uint16_t OutputMTU() const {
return (_omtu);
Expand Down
4 changes: 4 additions & 0 deletions Source/plugins/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ POP_WARNING()
_parent.Register();
}

string JobIdentifier() const {
return(_T("Thunder::RPC::PluginSmartInterfaceType::RegisterJob"));
}

private:
PluginSmartInterfaceType& _parent;
};
Expand Down

0 comments on commit d3a7a28

Please sign in to comment.