diff --git a/docs/about-conditional.md b/docs/about-conditional.md index 8433c675..ade00d2c 100644 --- a/docs/about-conditional.md +++ b/docs/about-conditional.md @@ -58,11 +58,13 @@ public: static WFConditional *create_conditional(const std::string& cond_name, SubTask *task, void **msgbuf); static int signal_by_name(const std::string& cond_name, void *msg); static int signal_by_name(const std::string& cond_name, void *msg, size_t max); + static int signal_by_name(const std::string& cond_name, void *const msg[], size_t max); }; ~~~ 我们看到,与普通条件任务唯一区别是,命名条件任务创建时,需要传入一个cond_name。 而signal_by_name()接口,默认将msg发送到所有在这个名称上等待的条件任务,将它们全部唤醒。 -也可以通过max参数指定唤醒的最大任务数。函数的返回值表示实际唤醒的个数。 +也可以通过max参数指定唤醒的最大任务数。此时,msg还可以是一个数组,可给不同的条件任务发送不同的消息。 +任何一个signal_by_name的重载函数,其返回值都是表示实际唤醒的条件任务个数。 这就相当于实现了观察者模式。 # 示例 diff --git a/docs/en/tutorial-09-http_file_server.md b/docs/en/tutorial-09-http_file_server.md index 02e3fa3a..f966d405 100644 --- a/docs/en/tutorial-09-http_file_server.md +++ b/docs/en/tutorial-09-http_file_server.md @@ -107,10 +107,10 @@ public: fio_callback_t callback); /* Interface with file path name */ - static WFFileIOTask *create_pread_task(const std::string& pathname, void *buf, size_t count, off_t offset, + static WFFileIOTask *create_pread_task(const std::string& path, void *buf, size_t count, off_t offset, fio_callback_t callback); - static WFFileIOTask *create_pwrite_task(const std::string& pathname, void *buf, size_t count, off_t offset, + static WFFileIOTask *create_pwrite_task(const std::string& path, void *buf, size_t count, off_t offset, fio_callback_t callback); }; ~~~ diff --git a/docs/tutorial-09-http_file_server.md b/docs/tutorial-09-http_file_server.md index 1fc9edd0..e0913b5a 100644 --- a/docs/tutorial-09-http_file_server.md +++ b/docs/tutorial-09-http_file_server.md @@ -102,10 +102,10 @@ public: ... /* Interface with file path name */ - static WFFileIOTask *create_pread_task(const std::string& pathname, void *buf, size_t count, off_t offset, + static WFFileIOTask *create_pread_task(const std::string& path, void *buf, size_t count, off_t offset, fio_callback_t callback); - static WFFileIOTask *create_pwrite_task(const std::string& pathname, void *buf, size_t count, off_t offset, + static WFFileIOTask *create_pwrite_task(const std::string& path, void *buf, size_t count, off_t offset, fio_callback_t callback); }; ~~~ diff --git a/src/factory/FileTaskImpl.cc b/src/factory/FileTaskImpl.cc index c7c82071..5d9de0a3 100644 --- a/src/factory/FileTaskImpl.cc +++ b/src/factory/FileTaskImpl.cc @@ -354,46 +354,46 @@ WFFileSyncTask *WFTaskFactory::create_fdsync_task(int fd, /* Factory functions with path name. */ -WFFileIOTask *WFTaskFactory::create_pread_task(const std::string& pathname, +WFFileIOTask *WFTaskFactory::create_pread_task(const std::string& path, void *buf, size_t count, off_t offset, fio_callback_t callback) { - return new __WFFilepreadTask(pathname, buf, count, offset, + return new __WFFilepreadTask(path, buf, count, offset, WFGlobal::get_io_service(), std::move(callback)); } -WFFileIOTask *WFTaskFactory::create_pwrite_task(const std::string& pathname, +WFFileIOTask *WFTaskFactory::create_pwrite_task(const std::string& path, const void *buf, size_t count, off_t offset, fio_callback_t callback) { - return new __WFFilepwriteTask(pathname, buf, count, offset, + return new __WFFilepwriteTask(path, buf, count, offset, WFGlobal::get_io_service(), std::move(callback)); } -WFFileVIOTask *WFTaskFactory::create_preadv_task(const std::string& pathname, +WFFileVIOTask *WFTaskFactory::create_preadv_task(const std::string& path, const struct iovec *iovec, int iovcnt, off_t offset, fvio_callback_t callback) { - return new __WFFilepreadvTask(pathname, iovec, iovcnt, offset, + return new __WFFilepreadvTask(path, iovec, iovcnt, offset, WFGlobal::get_io_service(), std::move(callback)); } -WFFileVIOTask *WFTaskFactory::create_pwritev_task(const std::string& pathname, +WFFileVIOTask *WFTaskFactory::create_pwritev_task(const std::string& path, const struct iovec *iovec, int iovcnt, off_t offset, fvio_callback_t callback) { - return new __WFFilepwritevTask(pathname, iovec, iovcnt, offset, + return new __WFFilepwritevTask(path, iovec, iovcnt, offset, WFGlobal::get_io_service(), std::move(callback)); } diff --git a/src/factory/WFTaskFactory.h b/src/factory/WFTaskFactory.h index e45d3bff..b985cc9d 100644 --- a/src/factory/WFTaskFactory.h +++ b/src/factory/WFTaskFactory.h @@ -193,25 +193,25 @@ public: /* File tasks with path name. */ public: - static WFFileIOTask *create_pread_task(const std::string& pathname, + static WFFileIOTask *create_pread_task(const std::string& path, void *buf, size_t count, off_t offset, fio_callback_t callback); - static WFFileIOTask *create_pwrite_task(const std::string& pathname, + static WFFileIOTask *create_pwrite_task(const std::string& path, const void *buf, size_t count, off_t offset, fio_callback_t callback); - static WFFileVIOTask *create_preadv_task(const std::string& pathname, + static WFFileVIOTask *create_preadv_task(const std::string& path, const struct iovec *iov, int iovcnt, off_t offset, fvio_callback_t callback); - static WFFileVIOTask *create_pwritev_task(const std::string& pathname, + static WFFileVIOTask *create_pwritev_task(const std::string& path, const struct iovec *iov, int iovcnt, off_t offset,