Merge branch 'master' of https://github.com/sogou/workflow into nossl

This commit is contained in:
Xie Han
2024-11-09 15:54:58 +08:00
5 changed files with 19 additions and 17 deletions
+3 -1
View File
@@ -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的重载函数,其返回值都是表示实际唤醒的条件任务个数。
这就相当于实现了观察者模式。
# 示例
+2 -2
View File
@@ -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);
};
~~~
+2 -2
View File
@@ -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);
};
~~~
+8 -8
View File
@@ -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));
}
+4 -4
View File
@@ -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,