From af042f6a248afa01b882c6f41ad068d28036e84c Mon Sep 17 00:00:00 2001 From: tqchen Date: Sat, 25 Jul 2015 21:14:50 -0700 Subject: [PATCH] make things cxx98 compatible --- src/utils/thread_buffer.h | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/utils/thread_buffer.h b/src/utils/thread_buffer.h index 2119f53ab..c4dc1185d 100644 --- a/src/utils/thread_buffer.h +++ b/src/utils/thread_buffer.h @@ -11,9 +11,14 @@ #include #include #include "./utils.h" +// threading util could not run on solaris +#ifndef XGBOOST_STRICT_CXX98_ #include "./thread.h" +#endif + namespace xgboost { namespace utils { +#if !defined(XGBOOST_STRICT_CXX98_) /*! * \brief buffered loading iterator that uses multithread * this template method will assume the following paramters @@ -201,6 +206,52 @@ class ThreadBuffer { loading_need.Post(); } }; +#else +// a dummy single threaded ThreadBuffer +// use this to resolve R's solaris compatibility for now +template +class ThreadBuffer { + public: + ThreadBuffer() : init_end_(false) {} + ~ThreadBuffer() { + if (init_end_) { + factory_.FreeSpace(data_); + factory_.Destroy(); + } + } + inline void SetParam(const char *name, const char *val) { + } + inline bool Init(void) { + if (!factory_.Init()) return false; + data_ = factory_.Create(); + return (init_end_ = true); + } + inline void BeforeFirst(void) { + factory_.BeforeFirst(); + } + inline bool Next(Elem &elem) { // NOLINT(*) + if (factory_.LoadNext(data_)) { + elem = data_; return true; + } else { + return false; + } + } + inline ElemFactory &get_factory() { + return factory_; + } + inline const ElemFactory &get_factory() const { + return factory_; + } + + private: + // initialized + bool init_end_; + // current data + Elem data_; + // factory object used to load configures + ElemFactory factory_; +}; +#endif // !defined(XGBOOST_STRICT_CXX98_) } // namespace utils } // namespace xgboost #endif // XGBOOST_UTILS_THREAD_BUFFER_H_