Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
DrOctavius committed Sep 5, 2023
1 parent 24bc8c3 commit bd0725c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
35 changes: 35 additions & 0 deletions testing/channels/channel_async_buffer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"github.com/google/uuid"
"log"
"time"
)

func main() {

myChannel := make(chan uuid.UUID, 2)

go func() {
for {
select {
case data := <-myChannel:
log.Println(data, "sleeping... 3 sec")
time.Sleep(time.Second * 3)
}
}
}()

for i := 0; i <= 3; i++ {
id, _ := uuid.NewRandom()
log.Println("pushing", id)
//go func() {
myChannel <- id
//}()
log.Println("pushed", id)
}

log.Println("finished pushing data to channel")

time.Sleep(time.Second * 10)
}
35 changes: 35 additions & 0 deletions testing/channels/channel_async_buffer2/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"github.com/google/uuid"
"log"
"time"
)

func main() {

myChannel := make(chan uuid.UUID, 2)

go func() {
for {
select {
case data := <-myChannel:
log.Println(data, "sleeping... 3 sec")
time.Sleep(time.Second * 3)
}
}
}()

for i := 0; i <= 3; i++ {
id, _ := uuid.NewRandom()
log.Println("pushing", id)
go func() {
myChannel <- id
}()
log.Println("pushed", id)
}

log.Println("finished pushing data to channel")

time.Sleep(time.Second * 10)
}

0 comments on commit bd0725c

Please sign in to comment.