cjolivier01 commented on a change in pull request #8972: Profiling 
enhancements, python API, vtune and chrome tracing objects, etc.
URL: https://github.com/apache/incubator-mxnet/pull/8972#discussion_r164221517
 
 

 ##########
 File path: src/engine/thread_pool.h
 ##########
 @@ -39,40 +40,17 @@ namespace engine {
  */
 class ThreadPool {
  public:
-  /*! \brief Simple manually-signalled event gate which remains open */
-  class SimpleEvent {
-   public:
-    SimpleEvent()
-      : signaled_(false) {}
-    void wait() {
-      std::unique_lock<std::mutex> lock(mutex_);
-      if (!signaled_) {
-        condition_variable_.wait(lock);
-      }
-    }
-    void signal() {
-      signaled_ = true;
-      std::unique_lock<std::mutex> lk(mutex_);
-      condition_variable_.notify_all();
+  /*! \brief Signal event upon destruction, even for exceptions (RAII) */
+  struct SetReadyOnDestroy {
+    explicit inline SetReadyOnDestroy(std::shared_ptr<dmlc::ManualEvent> 
*event)
+      : event_(*event) {
     }
-
-    /*! \brief Signal event upon destruction, even for exceptions (RAII) */
-    struct SetReadyOnDestroy {
-      explicit inline SetReadyOnDestroy(std::shared_ptr<SimpleEvent> *event)
-        : event_(*event) {
+    inline ~SetReadyOnDestroy() {
+      if (event_) {
+        event_->signal();
       }
-      inline ~SetReadyOnDestroy() {
-        if (event_) {
-          event_->signal();
-        }
-      }
-      std::shared_ptr<SimpleEvent>  event_;
-    };
-
-   private:
-    std::mutex              mutex_;
-    std::condition_variable condition_variable_;
-    std::atomic<bool>       signaled_;
+    }
+    std::shared_ptr<dmlc::ManualEvent>  event_;
 
 Review comment:
   Since the event comes from a different thread with a different lifecycle 
(passed to GPUWorker constructor, for instance), the reference count helps to 
protect the object in case the original owner gets destroyed (and this destroys 
the event object).  I try not to create copies, thus causing more superfluous 
reference counts during general use.  

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to