huajsj commented on code in PR #11018:
URL: https://github.com/apache/tvm/pull/11018#discussion_r862277313
##########
include/tvm/runtime/threading_backend.h:
##########
@@ -110,6 +110,37 @@ class ThreadGroup {
Impl* impl_;
};
+class ThreadGroup::Impl {
+ public:
+ virtual void Join() {}
+ virtual int Configure(AffinityMode mode, int nthreads, bool exclude_worker0,
+ std::vector<unsigned int> cpus) = 0;
+ virtual ~Impl() { Join(); }
+};
+
+template <class ThreadType>
+class ThreadGroupImplTemplate : public ThreadGroup::Impl {
+ public:
+ virtual void Join() {
+ for (auto& t : threads_) {
+ if (t.joinable()) t.join();
+ }
+ }
+
Review Comment:
~ThreadGroupImplTemplate() { Join();}
##########
include/tvm/runtime/threading_backend.h:
##########
@@ -110,6 +110,37 @@ class ThreadGroup {
Impl* impl_;
};
+class ThreadGroup::Impl {
+ public:
+ virtual void Join() {}
+ virtual int Configure(AffinityMode mode, int nthreads, bool exclude_worker0,
+ std::vector<unsigned int> cpus) = 0;
+ virtual ~Impl() { Join(); }
Review Comment:
seems like here is to expect ThreadGroupImplTemplate:Join get triggered, but
that may not happen, because the calling is in a deconstruct function.
##########
include/tvm/runtime/threading_backend.h:
##########
@@ -110,6 +110,37 @@ class ThreadGroup {
Impl* impl_;
};
+class ThreadGroup::Impl {
+ public:
+ virtual void Join() {}
Review Comment:
"virtual void Join() = 0" or {assert(0);} to make sure inherit class have a
dedicated "Join" and get called.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]