Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pilot committed Oct 18, 2023
1 parent 1eb68af commit 5b8da34
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,28 @@ To start using `event`, just run `go get`:
$ go get -u github.com/cheng-zhongliang/event
```

### Events
### Event

- `EvRead` fires when the fd is readable.
- `EvWrite` fires when the fd is writable.
- `EvTimeout` fires when the timeout expires.
- `EvPersist` __if not set, the event will be deleted after it is triggered.__

When the event is triggered, the callback function will be called.

### Option

The event is one-shot by default. If you want to persist, you can set the `EvPersist` option.

```go
ev := event.New(base, fd, event.EvRead|event.EvPersist, callback, arg)
```

The event is level-triggered by default. If you want to use edge-triggered, you can set the `EvET` option.

```go
ev := event.New(base, fd, event.EvRead|event.EvET, callback, arg)
```

### Read/Write/Timeout

These events can be used in combination.
Expand Down Expand Up @@ -90,14 +103,6 @@ ev := event.New(base, fd, event.EvRead|event.EvET, callback, arg)
ev.SetPriority(event.HPri)
```

### Edge-triggered

The event is level-triggered by default. If you want to use edge-triggered, you can set the `EvET` flag.

```go
ev := event.New(base, fd, event.EvRead|event.EvET, callback, arg)
```

### Usage

Example echo server that binds to port 1246:
Expand Down

0 comments on commit 5b8da34

Please sign in to comment.