This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select { | |
case <-ch: | |
// channel is closed, this is executed | |
default: | |
// channel is still open, the previous case is not executed | |
close(ch) | |
} | |
once := sync.Once{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Test_double_check_unsafe(t *testing.T) { | |
m := make(map[int]int64) | |
mu := sync.Mutex{} | |
wg := sync.WaitGroup{} | |
wg.Add(100 * 10) | |
for i := 0; i < 100; i++ { | |
for j := 0; j < 10; j++ { | |
go func(j int) { | |
defer wg.Done() | |
v := m[j] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m := make(map[[8]byte][]int64, 1e8) | |
for i := 0; i < 10; i++ { | |
start := time.Now() | |
runtime.GC() | |
fmt.Printf("GC took %s\n", time.Since(start)) | |
} | |
runtime.KeepAlive(m) | |
//x := 10 | |
//var mx [x]int | |
//fmt.Println(mx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func floatSlice2bytes(s []float64) []byte { | |
b := (*reflect.SliceHeader)(unsafe.Pointer(&s)) | |
b.Cap = b.Cap * 8 | |
b.Len = b.Len * 8 | |
return *(*[]byte)(unsafe.Pointer(&s)) | |
} | |
func bytes2floatSlice(s []byte) []float64 { | |
b := (*reflect.SliceHeader)(unsafe.Pointer(&s)) | |
b.Cap = b.Cap / 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! Put user rules line by line in this file. | |
! See https://adblockplus.org/en/filter-cheatsheet | |
||redis.io | |
||segment.com | |
||todoist.com | |
||cheney.net | |
||cncf.io | |
||influxdata.com | |
||quora.com | |
||todoist.com |