Recent Posts

DesignOfEverydayThings - Signifier - 1

Affordance: it is a relationship, ex. Affordance of touching exists on the entire screen Signifier: designer put a circle on screen to signify user where t...

DesignOfEverydayThings - Affordances

Chair affordance An affordance is a relationship between the properties of an object and the capabilities of the agent that determine just how the objec...

DesignOfEverydayThings - Norman Doors

Introduction I like this book very much! I always can learn from it. Have a chance to introduce this book to team, want to have some notes for "THE PS...

Go - read write lock

Add number to 10000. RWLock (Use Lock/Unlock to read): 19ms, 92202 read count RWLock (Use RLock/RUnlock to read): 597ms, 4789798 read count W...

Go - mutual exclusion

Ex. Binary semaphore Race Condition Semaphore Ex. sync.Mutex Mutex.Unlock happens before Mutex.Lock Every Lock needs Unlock, can use defe...

Go - prevent race condition

Prevent race condition Initialize variables when package initialization phase, it will happen before main function. And don't modify those variables a...

Go - Cancel Job by close channel

Close a channel to broadcast cancellation No way to know a channel is closed or not, so need another channel to indicate a channel is closed This exa...

Go - Select Channel

Declare select {     case <- ch:         ...     case x := <- ch2:       &...

Go - parallel iteration

Inner goroutine can send event to outer goroutine by channel Ex. Pass value to inner routine function Declare a variable in inner goroutine function, ...

Go - buffered channel

Declare a queue: ch := make(chan int, 3) Block send when full, block receive when empty Get capacity: cap(ch) Get currently buffered: len(ch) ...

Go - unidirectional channel

Send only: chan<- int Receive only: <-chan int Violation will compile error Only channel used to send msg need to be closed, so to cl...