Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
idealvin committed Oct 8, 2022
1 parent cead3ec commit 9d78b93
Show file tree
Hide file tree
Showing 50 changed files with 74 additions and 74 deletions.
6 changes: 3 additions & 3 deletions content/cn/co/atomic.md
Expand Up @@ -3,12 +3,12 @@ weight: 2
title: "原子操作"
---

include: [co/atomic.h](https://github.com/idealvin/co/tree/master/include/co/atomic.h).
include: [co/atomic.h](https://github.com/idealvin/coost/tree/master/include/co/atomic.h).


## Memory Order

co 从 v3.0 开始,增加了对 memory order 的支持。co 中的 6 种 memory order 定义如下:
coost 从 v3.0 开始,增加了对 memory order 的支持。coost 中的 6 种 memory order 定义如下:

```cpp
enum memory_order_t {
Expand All @@ -21,7 +21,7 @@ enum memory_order_t {
};
```

为了保持兼容性,co 中的原子操作默认的 memory order 均为 `mo_seq_cst`
为了保持兼容性,coost 中的原子操作默认的 memory order 均为 `mo_seq_cst`



Expand Down
8 changes: 4 additions & 4 deletions content/cn/co/build.md
Expand Up @@ -128,7 +128,7 @@ xmake -v

#### Android 与 IOS 支持

CO 在 Android 与 IOS 平台也能编译,详情见 [Github Actions](https://github.com/idealvin/co/actions)。由于作者没有前端开发的经验,暂时未在 Android 与 IOS 上测试。
CO 在 Android 与 IOS 平台也能编译,详情见 [Github Actions](https://github.com/idealvin/coost/actions)。由于作者没有前端开发的经验,暂时未在 Android 与 IOS 上测试。

- android

Expand All @@ -148,7 +148,7 @@ xmake -v

### 构建及运行 unitest 代码

[co/unitest](https://github.com/idealvin/co/tree/master/unitest) 是单元测试代码,可以执行下述命令构建及运行:
[co/unitest](https://github.com/idealvin/coost/tree/master/unitest) 是单元测试代码,可以执行下述命令构建及运行:

```bash
xmake -b unitest # build unitest
Expand All @@ -161,7 +161,7 @@ xmake r unitest -json # 执行单元测试 json

### 构建及运行 test 代码

[co/test](https://github.com/idealvin/co/tree/master/test) 是一些测试代码,在 co/test 目录或其子目录下增加 `xx.cc` 源文件,然后在 CO 根目录下执行 `xmake -b xx` 即可构建。
[co/test](https://github.com/idealvin/coost/tree/master/test) 是一些测试代码,在 co/test 目录或其子目录下增加 `xx.cc` 源文件,然后在 CO 根目录下执行 `xmake -b xx` 即可构建。

```bash
xmake -b flag # 编译 test/flag.cc
Expand All @@ -188,7 +188,7 @@ cp gen /usr/local/bin/
gen hello_world.proto
```

proto 文件格式可以参考 [hello_world.proto](https://github.com/idealvin/co/blob/master/test/so/rpc/hello_world.proto)
proto 文件格式可以参考 [hello_world.proto](https://github.com/idealvin/coost/blob/master/test/so/rpc/hello_world.proto)



Expand Down
8 changes: 4 additions & 4 deletions content/cn/co/coroutine.md
Expand Up @@ -3,7 +3,7 @@ weight: 11
title: "协程"
---

include: [co/co.h](https://github.com/idealvin/co/blob/master/include/co/co.h).
include: [co/co.h](https://github.com/idealvin/coost/blob/master/include/co/co.h).


## 基本概念
Expand Down Expand Up @@ -1269,7 +1269,7 @@ IoEvent(sock_t fd, int n=0); // for windows only
- 构造函数,linux 与 mac 平台只提供第 1 个版本,windows 平台还提供第 2 个版本。
- 第 1 个版本中,**参数 fd 是一个 non-blocking socket**,参数 ev 是 I/O 事件类型,只能是 co::ev_read 或 co::ev_write 中的一种。调用 wait() 方法会在 socket 上等待 ev 指定的 I/O 事件,wait() 成功返回时,需要用户调用 recv, send 等函数完成 I/O 操作。**在 windows 平台,fd 必须是 TCP socket**(对于 UDP,很难用 IOCP 模拟 epoll 或 kqueue 的行为)。
- 第 2 个版本仅适用于 windows,与第 1 个版本不同,fd 可以是 UDP socket,但用户需要手动调用 WSARecvFrom, WSASendTo 等函数向 IOCP 发送 overlapped I/O 请求,然后调用 wait() 方法,当 wait() 成功返回时,表示 IOCP 已经帮用户完成了 I/O 操作。具体的用法此处不详述,代码中有详细的注释,建议直接参考 [co::IoEvent 的源码](https://github.com/idealvin/co/blob/master/include/co/co/io_event.h),以及 windows 上 [co::accept, co::connect, co::recvfrom, co::sendto 的实现](https://github.com/idealvin/co/blob/master/src/co/sock_win.cc)。
- 第 2 个版本仅适用于 windows,与第 1 个版本不同,fd 可以是 UDP socket,但用户需要手动调用 WSARecvFrom, WSASendTo 等函数向 IOCP 发送 overlapped I/O 请求,然后调用 wait() 方法,当 wait() 成功返回时,表示 IOCP 已经帮用户完成了 I/O 操作。具体的用法此处不详述,代码中有详细的注释,建议直接参考 [co::IoEvent 的源码](https://github.com/idealvin/coost/blob/master/include/co/co/io_event.h),以及 windows 上 [co::accept, co::connect, co::recvfrom, co::sendto 的实现](https://github.com/idealvin/coost/blob/master/src/co/sock_win.cc)。
Expand Down Expand Up @@ -1415,7 +1415,7 @@ go(server_fun);
- 在一个协程中,调用 `co::accept()` 接受客户端连接。
- 有连接到来时,创建一个新的协程,在协程中处理连接上的数据。
- `on_connection()` 是处理连接的协程函数,接收、处理与发送数据,在该协程中以完全同步的方式进行,不需要任何异步回调。
- 完整的实现可以参考 [co 中的测试代码](https://github.com/idealvin/co/blob/master/test/so/tcp2.cc)
- 完整的实现可以参考 [co 中的测试代码](https://github.com/idealvin/coost/blob/master/test/so/tcp2.cc)



Expand All @@ -1436,7 +1436,7 @@ go(client_fun);
```
- 建立连接,发送、接收、处理数据,在协程中以完全同步的方式进行。
- 完整的实现可以参考 [co 中的测试代码](https://github.com/idealvin/co/blob/master/test/so/tcp2.cc)。
- 完整的实现可以参考 [co 中的测试代码](https://github.com/idealvin/coost/blob/master/test/so/tcp2.cc)。
实际应用中,一般使用 **co::Pool** 作为连接池,以避免创建过多的连接:
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/def.md
Expand Up @@ -3,7 +3,7 @@ weight: 1
title: "基本定义"
---

include: [co/def.h](https://github.com/idealvin/co/blob/master/include/co/def.h).
include: [co/def.h](https://github.com/idealvin/coost/blob/master/include/co/def.h).


## typedefs
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/defer.md
Expand Up @@ -3,7 +3,7 @@ weight: 2
title: "defer"
---

include: [co/defer.h](https://github.com/idealvin/co/blob/master/include/co/defer.h).
include: [co/defer.h](https://github.com/idealvin/coost/blob/master/include/co/defer.h).


## defer
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/fastream.md
Expand Up @@ -3,7 +3,7 @@ weight: 3
title: "字符流(fastream)"
---

include: [co/fastream.h](https://github.com/idealvin/co/blob/master/include/co/fastream.h).
include: [co/fastream.h](https://github.com/idealvin/coost/blob/master/include/co/fastream.h).


## fastream
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/fastring.md
Expand Up @@ -3,7 +3,7 @@ weight: 2
title: "字符串(fastring)"
---

include: [co/fastring.h](https://github.com/idealvin/co/blob/master/include/co/fastring.h).
include: [co/fastring.h](https://github.com/idealvin/coost/blob/master/include/co/fastring.h).


## fastring
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/flag.md
Expand Up @@ -3,7 +3,7 @@ weight: 5
title: "命令行参数与配置文件解析"
---

include: [co/flag.h](https://github.com/idealvin/co/blob/master/include/co/flag.h).
include: [co/flag.h](https://github.com/idealvin/coost/blob/master/include/co/flag.h).


## 基本概念
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/fs.md
Expand Up @@ -4,7 +4,7 @@ title: "文件系统"
---


include: [co/fs.h](https://github.com/idealvin/co/blob/master/include/co/fs.h).
include: [co/fs.h](https://github.com/idealvin/coost/blob/master/include/co/fs.h).


`co/fs.h` 最小限度的实现了常用的文件系统操作,不同平台路径分隔符建议统一使用 `'/'`
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/hash.md
Expand Up @@ -4,7 +4,7 @@ title: "Hash"
---


include: [co/hash.h](https://github.com/idealvin/co/blob/master/include/co/hash.h).
include: [co/hash.h](https://github.com/idealvin/coost/blob/master/include/co/hash.h).


## Hash
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/json.md
Expand Up @@ -3,7 +3,7 @@ weight: 8
title: "JSON"
---

include: [co/json.h](https://github.com/idealvin/co/blob/master/include/co/json.h).
include: [co/json.h](https://github.com/idealvin/coost/blob/master/include/co/json.h).


`co/json` 是一个类似 [rapidjson](https://github.com/Tencent/rapidjson) 的 JSON 库,与 rapidjson 相比,它既有性能上的优势,同时又更简单易用。
Expand Down
4 changes: 2 additions & 2 deletions content/cn/co/log.md
Expand Up @@ -3,7 +3,7 @@ weight: 6
title: "日志"
---

include: [co/log.h](https://github.com/idealvin/co/blob/master/include/co/log.h).
include: [co/log.h](https://github.com/idealvin/coost/blob/master/include/co/log.h).


## 简介
Expand Down Expand Up @@ -474,5 +474,5 @@ xmake r log -min_log_level=1 # 0-4: debug,info,warning,error,fatal
xmake r log -perf # performance test
```

- 在 co 根目录执行 `xmake -b log` 即可编译 [test/log.cc](https://github.com/idealvin/co/blob/master/test/log.cc) 测试代码,并生成 `log` 二进制文件。
- 在 co 根目录执行 `xmake -b log` 即可编译 [test/log.cc](https://github.com/idealvin/coost/blob/master/test/log.cc) 测试代码,并生成 `log` 二进制文件。

2 changes: 1 addition & 1 deletion content/cn/co/lrumap.md
Expand Up @@ -4,7 +4,7 @@ title: "LruMap"
---


include: [co/lru_map.h](https://github.com/idealvin/co/blob/master/include/co/lru_map.h).
include: [co/lru_map.h](https://github.com/idealvin/coost/blob/master/include/co/lru_map.h).


## LruMap
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/net/byte_order.md
Expand Up @@ -4,7 +4,7 @@ title: "字节序"
---


include: [co/byte_order.h](https://github.com/idealvin/co/blob/master/include/co/byte_order.h).
include: [co/byte_order.h](https://github.com/idealvin/coost/blob/master/include/co/byte_order.h).


计算机中的数据在内存中是以字节(8 bit)为基本单位进行存储的,大端机采用大端字节序,即高位字节在低地址,低位字节在高地址,小端机则采用小端字节序,即低位字节在低地址,高位字节在高地址。
Expand Down
4 changes: 2 additions & 2 deletions content/cn/co/net/http.md
Expand Up @@ -4,7 +4,7 @@ title: "HTTP"
---


include: [co/http.h](https://github.com/idealvin/co/blob/master/include/co/http.h).
include: [co/http.h](https://github.com/idealvin/coost/blob/master/include/co/http.h).


## http::Client
Expand Down Expand Up @@ -490,7 +490,7 @@ http::Server().on_req(cb).start(
);
```

`co/test` 提供了一个简单的 [demo](https://github.com/idealvin/co/blob/master/test/so/http_serv.cc),用户可以按下述方式编译运行:
`co/test` 提供了一个简单的 [demo](https://github.com/idealvin/coost/blob/master/test/so/http_serv.cc),用户可以按下述方式编译运行:

```bash
xmake -b http_serv
Expand Down
4 changes: 2 additions & 2 deletions content/cn/co/net/rpc.md
Expand Up @@ -4,7 +4,7 @@ title: "RPC"
---


include: [co/rpc.h](https://github.com/idealvin/co/blob/master/include/co/rpc.h).
include: [co/rpc.h](https://github.com/idealvin/coost/blob/master/include/co/rpc.h).


co/rpc 是一个类似 [grpc](https://github.com/grpc/grpc) 的高性能 RPC 框架,它内部使用 **JSON** 格式传输数据,而不是 protobuf 等二进制协议。从 v3.0 开始,co/rpc 同时支持 HTTP 协议,可以用 HTTP 的 POST 方法调用 rpc 服务。
Expand Down Expand Up @@ -114,7 +114,7 @@ service HelloWorld {

### 生成 service 代码

[gen](https://github.com/idealvin/co/tree/master/gen) 是 co 提供的 RPC 代码生成器,它可以生成 service 相关代码。
[gen](https://github.com/idealvin/coost/tree/master/gen) 是 co 提供的 RPC 代码生成器,它可以生成 service 相关代码。

```bash
xmake -b gen # 构建 gen
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/net/tcp.md
Expand Up @@ -4,7 +4,7 @@ title: "TCP"
---


include: [co/tcp.h](https://github.com/idealvin/co/blob/master/include/co/tcp.h).
include: [co/tcp.h](https://github.com/idealvin/coost/blob/master/include/co/tcp.h).


## tcp::Connection
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/os.md
Expand Up @@ -4,7 +4,7 @@ title: "操作系统"
---


include: [co/os.h](https://github.com/idealvin/co/blob/master/include/co/os.h).
include: [co/os.h](https://github.com/idealvin/coost/blob/master/include/co/os.h).


## os
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/path.md
Expand Up @@ -4,7 +4,7 @@ title: "文件路径(path)"
---


include: [co/path.h](https://github.com/idealvin/co/blob/master/include/co/path.h).
include: [co/path.h](https://github.com/idealvin/coost/blob/master/include/co/path.h).


## path
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/random.md
Expand Up @@ -3,7 +3,7 @@ weight: 18
title: "随机数"
---

include: [co/random.h](https://github.com/idealvin/co/blob/master/include/co/random.h).
include: [co/random.h](https://github.com/idealvin/coost/blob/master/include/co/random.h).


## Random
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/str.md
Expand Up @@ -3,7 +3,7 @@ weight: 4
title: "字符串操作"
---

include: [co/str.h](https://github.com/idealvin/co/tree/master/include/co/str.h).
include: [co/str.h](https://github.com/idealvin/coost/tree/master/include/co/str.h).


## 切分、修剪、替换、连接
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/tasked.md
Expand Up @@ -4,7 +4,7 @@ title: "定时任务"
---


include: [co/tasked.h](https://github.com/idealvin/co/blob/master/include/co/tasked.h).
include: [co/tasked.h](https://github.com/idealvin/coost/blob/master/include/co/tasked.h).


## Tasked
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/thread.md
Expand Up @@ -3,7 +3,7 @@ weight: 10
title: "线程"
---

include: [co/thread.h](https://github.com/idealvin/co/blob/master/include/co/thread.h).
include: [co/thread.h](https://github.com/idealvin/coost/blob/master/include/co/thread.h).


## 线程(Thread)
Expand Down
2 changes: 1 addition & 1 deletion content/cn/co/time.md
Expand Up @@ -3,7 +3,7 @@ weight: 9
title: "时间"
---

include: [co/time.h](https://github.com/idealvin/co/blob/master/include/co/time.h).
include: [co/time.h](https://github.com/idealvin/coost/blob/master/include/co/time.h).


## epoch time
Expand Down
4 changes: 2 additions & 2 deletions content/cn/co/unitest.md
Expand Up @@ -3,7 +3,7 @@ weight: 7
title: "单元测试框架"
---

include: [co/unitest.h](https://github.com/idealvin/co/blob/master/include/co/unitest.h).
include: [co/unitest.h](https://github.com/idealvin/coost/blob/master/include/co/unitest.h).


## 基本概念
Expand Down Expand Up @@ -177,7 +177,7 @@ int main(int argc, char** argv) {
xmake -b unitest
```

- 在 co 根目录执行上述命令,即可编译 [co/unitest](https://github.com/idealvin/co/tree/master/unitest) 目录下的单元测试代码,并生成 `unitest` 二进制程序。
- 在 co 根目录执行上述命令,即可编译 [co/unitest](https://github.com/idealvin/coost/tree/master/unitest) 目录下的单元测试代码,并生成 `unitest` 二进制程序。



Expand Down
8 changes: 4 additions & 4 deletions content/en/co/atomic.md
Expand Up @@ -3,7 +3,7 @@ weight: 2
title: "Atomic Operations"
---

include: [co/atomic.h](https://github.com/idealvin/co/tree/master/include/co/atomic.h).
include: [co/atomic.h](https://github.com/idealvin/coost/tree/master/include/co/atomic.h).


## Memory Order
Expand Down Expand Up @@ -442,9 +442,9 @@ template<typename T, typename V>
inline T atomic_xor(T* p, V v, memory_order_t mo = mo_seq_cst);
```
- Atomic bitwise XOR operation, T is any integer type with a length of 1, 2, 4, 8 bytes, V is any integer type, and the parameter p is a pointer of type T.
- Atomic bitwise `XOR` operation, T is any integer type with a length of 1, 2, 4, 8 bytes, V is any integer type, and the parameter p is a pointer of type T.
- This function performs a bitwise XOR operation on the integer pointed to by p and v, and returns the result of the operation.
- This function performs a bitwise `XOR` operation on the integer pointed to by p and v, and returns the result of the operation.
- Example
Expand All @@ -465,7 +465,7 @@ template<typename T, typename V>
inline T atomic_fetch_xor(T* p, V v, memory_order_t mo = mo_seq_cst);
```
- The same as [atomic_xor](#atomic_xor), but returns the value before the bitwise XOR operation.
- The same as [atomic_xor](#atomic_xor), but returns the value before the bitwise `XOR` operation.
- Example
Expand Down
8 changes: 4 additions & 4 deletions content/en/co/build.md
Expand Up @@ -111,7 +111,7 @@ xmake -v

#### Android and IOS support

CO can also be built on Android and IOS platforms, see [Github Actions](https://github.com/idealvin/co/actions) for details. Since the author has no front-end development experience, it has not been tested on Android and IOS.
CO can also be built on Android and IOS platforms, see [Github Actions](https://github.com/idealvin/coost/actions) for details. Since the author has no front-end development experience, it has not been tested on Android and IOS.

- android

Expand All @@ -131,7 +131,7 @@ xmake -v

### Build and run unitest code

[co/unitest](https://github.com/idealvin/co/tree/master/unitest) contains some unit test code, run the following commands to build and run the test program:
[co/unitest](https://github.com/idealvin/coost/tree/master/unitest) contains some unit test code, run the following commands to build and run the test program:

```bash
xmake -b unitest # build unitest
Expand All @@ -144,7 +144,7 @@ xmake r unitest -json # run unit test: json

### Build and run test code

[co/test](https://github.com/idealvin/co/tree/master/test) contains some test code, add `xx.cc` source file in the co/test directory or its subdirectories, and then run `xmake -b xx` in the root directory of CO to build it.
[co/test](https://github.com/idealvin/coost/tree/master/test) contains some test code, add `xx.cc` source file in the co/test directory or its subdirectories, and then run `xmake -b xx` in the root directory of CO to build it.

```bash
xmake -b flag # compile test/flag.cc
Expand All @@ -171,7 +171,7 @@ cp gen /usr/local/bin/
gen hello_world.proto
```

The proto file format can refer to [hello_world.proto](https://github.com/idealvin/co/blob/master/test/so/rpc/hello_world.proto).
The proto file format can refer to [hello_world.proto](https://github.com/idealvin/coost/blob/master/test/so/rpc/hello_world.proto).



Expand Down

0 comments on commit 9d78b93

Please sign in to comment.