From: @xiefangqi Reviewed-by: @heleiwang,@pandoublefeng Signed-off-by: @pandoublefengtags/v1.2.0-rc1
| @@ -14,7 +14,7 @@ | |||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "minddata/dataset/engine/cache/cache_request.h" | #include "minddata/dataset/engine/cache/cache_request.h" | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| #include <sched.h> | #include <sched.h> | ||||
| #include <sys/types.h> | #include <sys/types.h> | ||||
| #include <unistd.h> | #include <unistd.h> | ||||
| @@ -16,7 +16,7 @@ | |||||
| #include "minddata/dataset/util/services.h" | #include "minddata/dataset/util/services.h" | ||||
| #include <limits.h> | #include <limits.h> | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| #include <sys/syscall.h> | #include <sys/syscall.h> | ||||
| #else | #else | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| @@ -39,7 +39,7 @@ std::map<std::string, uint64_t> Services::unique_id_list_ = {}; | |||||
| uint64_t Services::unique_id_count_ = 0; | uint64_t Services::unique_id_count_ = 0; | ||||
| std::mutex Services::unique_id_mutex_; | std::mutex Services::unique_id_mutex_; | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| std::string Services::GetUserName() { | std::string Services::GetUserName() { | ||||
| char user[LOGIN_NAME_MAX]; | char user[LOGIN_NAME_MAX]; | ||||
| (void)getlogin_r(user, sizeof(user)); | (void)getlogin_r(user, sizeof(user)); | ||||
| @@ -66,7 +66,7 @@ class Services { | |||||
| std::shared_ptr<MemoryPool> GetServiceMemPool() { return pool_; } | std::shared_ptr<MemoryPool> GetServiceMemPool() { return pool_; } | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| static std::string GetUserName(); | static std::string GetUserName(); | ||||
| static std::string GetHostName(); | static std::string GetHostName(); | ||||
| @@ -25,7 +25,7 @@ | |||||
| namespace mindspore { | namespace mindspore { | ||||
| namespace dataset { | namespace dataset { | ||||
| // Register the custom signal handlers | // Register the custom signal handlers | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| void RegisterHandlers() { | void RegisterHandlers() { | ||||
| struct sigaction new_int_action; | struct sigaction new_int_action; | ||||
| @@ -22,7 +22,7 @@ | |||||
| namespace mindspore { | namespace mindspore { | ||||
| namespace dataset { | namespace dataset { | ||||
| // Register the custom signal handlers | // Register the custom signal handlers | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| extern void RegisterHandlers(); | extern void RegisterHandlers(); | ||||
| // A signal handler for SIGINT. Drives interrupt to watchdog | // A signal handler for SIGINT. Drives interrupt to watchdog | ||||
| @@ -42,7 +42,7 @@ void Task::operator()() { | |||||
| #endif | #endif | ||||
| MS_LOG(DEBUG) << my_name_ << " Thread ID " << ss.str() << " Started."; | MS_LOG(DEBUG) << my_name_ << " Thread ID " << ss.str() << " Started."; | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| native_handle_ = pthread_self(); | native_handle_ = pthread_self(); | ||||
| #endif | #endif | ||||
| @@ -200,7 +200,7 @@ Status Task::OverrideInterruptRc(const Status &rc) { | |||||
| return rc; | return rc; | ||||
| } | } | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| pthread_t Task::GetNativeHandle() const { return native_handle_; } | pthread_t Task::GetNativeHandle() const { return native_handle_; } | ||||
| #endif | #endif | ||||
| @@ -16,7 +16,7 @@ | |||||
| #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_H_ | #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_H_ | ||||
| #define MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_H_ | #define MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_H_ | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| #include <pthread.h> | #include <pthread.h> | ||||
| #endif | #endif | ||||
| #include <chrono> | #include <chrono> | ||||
| @@ -100,7 +100,7 @@ class Task : public IntrpResource { | |||||
| static Status OverrideInterruptRc(const Status &rc); | static Status OverrideInterruptRc(const Status &rc); | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| pthread_t GetNativeHandle() const; | pthread_t GetNativeHandle() const; | ||||
| #endif | #endif | ||||
| @@ -120,7 +120,7 @@ class Task : public IntrpResource { | |||||
| volatile bool running_; | volatile bool running_; | ||||
| volatile bool caught_severe_exception_; | volatile bool caught_severe_exception_; | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| pthread_t native_handle_; | pthread_t native_handle_; | ||||
| #else | #else | ||||
| uint64_t native_handle_; | uint64_t native_handle_; | ||||
| @@ -124,7 +124,7 @@ TaskManager::TaskManager() try : global_interrupt_(0), | |||||
| master_->is_master_ = true; | master_->is_master_ = true; | ||||
| #if !defined(_WIN32) && !defined(_WIN64) | #if !defined(_WIN32) && !defined(_WIN64) | ||||
| gMyTask = master_.get(); | gMyTask = master_.get(); | ||||
| #if !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| // Initialize the semaphore for the watchdog | // Initialize the semaphore for the watchdog | ||||
| errno_t rc = sem_init(&sem_, 0, 0); | errno_t rc = sem_init(&sem_, 0, 0); | ||||
| if (rc == -1) { | if (rc == -1) { | ||||
| @@ -147,14 +147,14 @@ TaskManager::~TaskManager() { | |||||
| watchdog_grp_ = nullptr; | watchdog_grp_ = nullptr; | ||||
| watchdog_ = nullptr; | watchdog_ = nullptr; | ||||
| } | } | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| (void)sem_destroy(&sem_); | (void)sem_destroy(&sem_); | ||||
| #endif | #endif | ||||
| } | } | ||||
| Status TaskManager::DoServiceStart() { | Status TaskManager::DoServiceStart() { | ||||
| MS_LOG(INFO) << "Starting Task Manager."; | MS_LOG(INFO) << "Starting Task Manager."; | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| // Create a watchdog for control-c | // Create a watchdog for control-c | ||||
| std::shared_ptr<MemoryPool> mp = Services::GetInstance().GetServiceMemPool(); | std::shared_ptr<MemoryPool> mp = Services::GetInstance().GetServiceMemPool(); | ||||
| // A dummy group just for the watchdog. We aren't really using it. But most code assumes a thread must | // A dummy group just for the watchdog. We aren't really using it. But most code assumes a thread must | ||||
| @@ -183,7 +183,7 @@ Status TaskManager::DoServiceStop() { | |||||
| Status TaskManager::WatchDog() { | Status TaskManager::WatchDog() { | ||||
| TaskManager::FindMe()->Post(); | TaskManager::FindMe()->Post(); | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| errno_t err = sem_wait(&sem_); | errno_t err = sem_wait(&sem_); | ||||
| if (err == -1) { | if (err == -1) { | ||||
| RETURN_STATUS_UNEXPECTED("Errno = " + std::to_string(errno)); | RETURN_STATUS_UNEXPECTED("Errno = " + std::to_string(errno)); | ||||
| @@ -16,7 +16,7 @@ | |||||
| #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_MANAGER_H_ | #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_MANAGER_H_ | ||||
| #define MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_MANAGER_H_ | #define MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_TASK_MANAGER_H_ | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| #include <semaphore.h> | #include <semaphore.h> | ||||
| #include <signal.h> // for sig_atomic_t | #include <signal.h> // for sig_atomic_t | ||||
| #endif | #endif | ||||
| @@ -92,7 +92,7 @@ class TaskManager : public Service { | |||||
| static void InterruptMaster(const Status &rc = Status::OK()); | static void InterruptMaster(const Status &rc = Status::OK()); | ||||
| static void WakeUpWatchDog() { | static void WakeUpWatchDog() { | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| TaskManager &tm = TaskManager::GetInstance(); | TaskManager &tm = TaskManager::GetInstance(); | ||||
| (void)sem_post(&tm.sem_); | (void)sem_post(&tm.sem_); | ||||
| #endif | #endif | ||||
| @@ -113,7 +113,7 @@ class TaskManager : public Service { | |||||
| std::shared_ptr<Task> master_; | std::shared_ptr<Task> master_; | ||||
| List<Task> lru_; | List<Task> lru_; | ||||
| List<Task> free_lst_; | List<Task> free_lst_; | ||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) | |||||
| #if !defined(_WIN32) && !defined(_WIN64) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__) | |||||
| sem_t sem_; | sem_t sem_; | ||||
| #endif | #endif | ||||
| TaskGroup *watchdog_grp_; | TaskGroup *watchdog_grp_; | ||||