mirror of
https://github.com/sogou/workflow.git
synced 2026-10-22 15:16:20 +08:00
Merge branch 'master' into master
This commit is contained in:
@@ -46,7 +46,7 @@ int main()
|
||||
|
||||
* This project supports `Linux`, `macOS`, `Windows`, `Android` and other operating systems.
|
||||
* `Windows` version is currently released as an independent [branch](https://github.com/sogou/workflow/tree/windows), using `iocp` to implement asynchronous networking. All user interfaces are consistent with the `Linux` version.
|
||||
* Supports all CPU platforms, including 32 or 64-bit `x86` processors, big-endian or little-endian `arm` processors.
|
||||
* Supports all CPU platforms, including 32 or 64-bit `x86` processors, big-endian or little-endian `arm` processors, `loongson` processors.
|
||||
* Relies on `OpenSSL`; `OpenSSL 1.1` and above is recommended. If you don't like SSL, you may checkout the [nossl](https://github.com/sogou/workflow/tree/nossl) branch. But still need to link `crypto` for `md5` and `sha1`.
|
||||
* Uses the `C++11` standard and therefore, it should be compiled with a compiler which supports `C++11`. Does not rely on `boost` or `asio`.
|
||||
* No other dependencies. However, if you need `Kafka` protocol, some compression libraries should be installed, including `lz4`, `zstd` and `snappy`.
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ int main()
|
||||
#### 编译和运行环境
|
||||
* 项目支持``Linux``,``macOS``,``Windows``,``Android``等操作系统。
|
||||
* ``Windows``版以[windows](https://github.com/sogou/workflow/tree/windows)分支发布,使用``iocp``实现异步网络。用户接口与``Linux``版一致。
|
||||
* 支持所有CPU平台,包括32或64位``x86``处理器,大端或小端``arm``处理器。
|
||||
* 支持所有CPU平台,包括32或64位``x86``处理器,大端或小端``arm``处理器,国产``loongson``龙芯处理器实测支持。
|
||||
* 需要依赖于``OpenSSL``,推荐``OpenSSL 1.1``及以上版本。
|
||||
* 不喜欢SSL的用户可以使用[nossl](https://github.com/sogou/workflow/tree/nossl)分支,代码更简洁。但仍需链接``crypto``。
|
||||
* 项目使用了``C++11``标准,需要用支持``C++11``的编译器编译。但不依赖``boost``或``asio``。
|
||||
|
||||
@@ -187,20 +187,3 @@ count_by_name("c1")等价于count_by_name("c1", 1)。
|
||||
虽然描述很复杂,但总结起来就一句话,按照创建顺序,依次访问所有名字为name的计数器,直到n为0。
|
||||
也就是说,一次count_by_name(name, n)可以唤醒多个计数器。
|
||||
用好计数器,可以实现非常复杂的业务逻辑。计数器在我们框架里,往往用于实现异步锁,或者用于任务之间的通道。形态上更像一种控制任务。
|
||||
|
||||
# 计数器的扩展WFContainerTask
|
||||
|
||||
计数器像一种信号量,每一个count操作,并不能附带操作数据,很多时候会带来一些不便。
|
||||
大家如果把计数器想象成有向无环图上的一个节点,每个count是一条入边。那么,节点上可以有属性的,但入边则没有包含任何信息。
|
||||
而WFContainerTask则是一种给入边加上属性的任务。在[WFContainerTask.h](../src/factory/WFContainerTask.h)里,有相关的定义:
|
||||
~~~cpp
|
||||
template<tyename T>
|
||||
class WFContainerTask : public WFCounterTask
|
||||
{
|
||||
public:
|
||||
void push(const T& value);
|
||||
void push(T&& value);
|
||||
...
|
||||
};
|
||||
~~~
|
||||
有需要的用户可以自行查阅相关代码。由于WFTaskFactory没有提供工厂函数,创造container任务需要自己调用new。
|
||||
|
||||
@@ -199,22 +199,3 @@ When you **call WFTaskFactory::count\_by\_name(name, n)**:
|
||||
Although the description is very complicated, it can be summed up in one sentence. Access all counters with that name according to the order of creation one by one until n is 0.
|
||||
In other words, one **count\_by\_name(name, n)** may wake up multiple counters.
|
||||
The counters can be used to realize very complex business logic if you can use them well. In our framework, counters are often used to implement asynchronous locks or to build channels between tasks. It is more like a control task in form.
|
||||
|
||||
# WFContainerTask - extension of a counter
|
||||
|
||||
A counter is like a kind of semaphore, and every count operation cannot be accompanied with operation data, which is often inconvenient.
|
||||
If you consider a counter as a node on a directed acyclic graph and each count is an incoming edge. Then, the node can have attributes, but the incoming edge does not contain any information.
|
||||
WFContainerTask is a task that adds attributes to the incoming edge. [WFContainerTask.h](/src/factory/WFContainerTask.h) contains relevant definitions:
|
||||
|
||||
~~~cpp
|
||||
template<tyename T>
|
||||
class WFContainerTask : public WFCounterTask
|
||||
{
|
||||
public:
|
||||
void push(const T& value);
|
||||
void push(T&& value);
|
||||
...
|
||||
};
|
||||
~~~
|
||||
|
||||
You can read the codes on demand. Since WFTaskFactory does not provide a factory function, you have to call **new** to create a container task.
|
||||
|
||||
Reference in New Issue
Block a user