Switch from Godep to go vendoring

This commit is contained in:
Ken-Håvard Lieng 2016-03-01 01:51:26 +01:00
parent 6b37713bc0
commit cd317761c5
1504 changed files with 263076 additions and 34441 deletions

27
vendor/github.com/matryer/resync/README.md generated vendored Normal file
View file

@ -0,0 +1,27 @@
# resync
`sync.Once` with `Reset()`
* See [sync.Once](http://golang.org/pkg/sync/#Once)
## Example
The following example examines how `resync.Once` could be used in a HTTP server situation.
```
// use it just like sync.Once
var once resync.Once
// handle a web request
func handleRequest(w http.ResponseWriter, r *http.Request) {
once.Do(func(){
// load templates or something
})
// TODO: respond
}
// handle some request that indicates things have changed
func handleResetRequest(w http.ResponseWriter, r *http.Request) {
once.Reset() // call Reset to cause initialisation to happen again above
}
```

38
vendor/github.com/matryer/resync/once.go generated vendored Normal file
View file

@ -0,0 +1,38 @@
package resync
import (
"sync"
"sync/atomic"
)
// Once is an object that will perform exactly one action
// until Reset is called.
// See http://golang.org/pkg/sync/#Once
type Once struct {
m sync.Mutex
done uint32
}
// Do simulates sync.Once.Do by executing the specified function
// only once, until Reset is called.
// See http://golang.org/pkg/sync/#Once
func (o *Once) Do(f func()) {
if atomic.LoadUint32(&o.done) == 1 {
return
}
// Slow-path.
o.m.Lock()
defer o.m.Unlock()
if o.done == 0 {
defer atomic.StoreUint32(&o.done, 1)
f()
}
}
// Reset indicates that the next call to Do should actually be called
// once again.
func (o *Once) Reset() {
o.m.Lock()
defer o.m.Unlock()
atomic.StoreUint32(&o.done, 0)
}

35
vendor/github.com/matryer/resync/once_test.go generated vendored Normal file
View file

@ -0,0 +1,35 @@
package resync_test
import (
"testing"
"github.com/cheekybits/is"
"github.com/matryer/resync"
)
func TestOnceReset(t *testing.T) {
is := is.New(t)
var calls int
var c resync.Once
c.Do(func() {
calls++
})
c.Do(func() {
calls++
})
c.Do(func() {
calls++
})
is.Equal(calls, 1)
c.Reset()
c.Do(func() {
calls++
})
c.Do(func() {
calls++
})
c.Do(func() {
calls++
})
is.Equal(calls, 2)
}