Skip to content

Commit

Permalink
Buffered Channels
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya43 committed May 30, 2021
1 parent f687b34 commit 654aeed
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,19 @@ value, ok = <- ch
-----------

## Unbuffered Channels:
- They are synchronous.
- Receiving channel will block until there is sender and sender will block until there is receiver.
- They are Synchronous.
- Receiving Goroutine will block until there is sender and sender will block until there is receiver.
- To create Unbuffered Channel:
```go
ch := make(chan int)
```
```

-----------

## Buffered Channels:
- They are Asynchronous.
- They are in-memory FIFO queues.
- There is a buffer between sender and receiver Goroutine.
- We can specify capacity i.e. Buffer size, which indicates the number of elemenets that can be sent without the receiver being ready.
- Sender can keep sending the values until buffer gets full. When the buffer gets full, the sender will get blocked.
- Receiver will keep receiving values until buffer gets empty. When the buffer gets empty, the receiver will get blocked.

0 comments on commit 654aeed

Please sign in to comment.