fix internal thread interface confusion
authorEvan Shelhamer <shelhamer@imaginarynumber.net>
Sun, 24 Aug 2014 05:41:30 +0000 (22:41 -0700)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>
Sun, 24 Aug 2014 05:41:30 +0000 (22:41 -0700)
thanks @ronghanghu for pointing this out in #964

include/caffe/internal_thread.hpp
src/caffe/layers/data_layer.cpp
src/caffe/layers/image_data_layer.cpp
src/caffe/layers/window_data_layer.cpp

index 8520899..bb0f932 100644 (file)
@@ -15,9 +15,9 @@ class InternalThread {
   InternalThread() {}
   virtual ~InternalThread() {}
 
-  /** Returns true if the thread was successfully started **/
+  /** Returns true if the thread was successfully started. **/
   bool StartInternalThread() {
-    return pthread_create(&_thread, NULL, InternalThreadEntryFunc, this);
+    return (pthread_create(&_thread, NULL, InternalThreadEntryFunc, this) == 0);
   }
 
   /** Will not return until the internal thread has exited. */
index b6ac5d6..0cc2769 100644 (file)
@@ -244,7 +244,7 @@ void DataLayer<Dtype>::CreatePrefetchThread() {
 
   data_transformer_.InitRand();
 
-  CHECK(!StartInternalThread()) << "Pthread execution failed";
+  CHECK(StartInternalThread()) << "Pthread execution failed";
 }
 
 template <typename Dtype>
index 85ee988..dc39e69 100644 (file)
@@ -159,7 +159,7 @@ void ImageDataLayer<Dtype>::CreatePrefetchThread() {
   data_transformer_.InitRand();
 
   // Create the thread.
-  CHECK(!StartInternalThread()) << "Pthread execution failed";
+  CHECK(StartInternalThread()) << "Pthread execution failed";
 }
 
 template <typename Dtype>
index 8138234..bed03d8 100644 (file)
@@ -408,7 +408,7 @@ void WindowDataLayer<Dtype>::CreatePrefetchThread() {
     prefetch_rng_.reset();
   }
   // Create the thread.
-  CHECK(!StartInternalThread()) << "Pthread execution failed.";
+  CHECK(StartInternalThread()) << "Pthread execution failed.";
 }
 
 template <typename Dtype>