Use dep to vendor things

This commit is contained in:
2018-03-18 04:23:13 +00:00
parent d572a19352
commit 1ba64f2aa8
123 changed files with 34229 additions and 0 deletions

21
vendor/github.com/faiface/mainthread/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Michal Štrba
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

71
vendor/github.com/faiface/mainthread/README.md generated vendored Normal file
View File

@@ -0,0 +1,71 @@
# mainthread [![GoDoc](https://godoc.org/github.com/faiface/mainthread?status.svg)](http://godoc.org/github.com/faiface/mainthread) [![Report card](https://goreportcard.com/badge/github.com/faiface/mainthread)](https://goreportcard.com/report/github.com/faiface/mainthread)
Package mainthread allows you to run code on the main operating system thread.
`go get github.com/faiface/mainthread`
Operating systems often require, that code which deals with windows and graphics has to run on the
main thread. This is however somehow challenging in Go due to Go's concurrent nature.
This package makes it easily possible.
All you need to do is put your main code into a separate function and call `mainthread.Run` from
your real main, like this:
```go
package main
import (
"fmt"
"github.com/faiface/mainthread"
)
func run() {
// now we can run stuff on the main thread like this
mainthread.Call(func() {
fmt.Println("printing from the main thread")
})
fmt.Println("printing from another thread")
}
func main() {
mainthread.Run(run) // enables mainthread package and runs run in a separate goroutine
}
```
## More functions
If you don't wish to wait until a function finishes running on the main thread, use
`mainthread.CallNonBlock`:
```go
mainthread.CallNonBlock(func() {
fmt.Println("i'm in the main thread")
})
fmt.Println("but imma be likely printed first, cuz i don't wait")
```
If you want to get some value returned from the main thread, you can use `mainthread.CallErr` or
`mainthread.CallVal`:
```go
err := mainthread.CallErr(func() error {
return nil // i don't do nothing wrong
})
val := mainthread.CallVal(func() interface{} {
return 42 // the meaning of life, universe and everything
})
```
If `mainthread.CallErr` or `mainthread.CallVal` aren't sufficient for you, you can just assign
variables from within the main thread:
```go
var x, y int
mainthread.Call(func() {
x, y = 1, 2
})
```
However, be careful with `mainthread.CallNonBlock` when dealing with local variables.

87
vendor/github.com/faiface/mainthread/mainthread.go generated vendored Normal file
View File

@@ -0,0 +1,87 @@
package mainthread
import (
"errors"
"runtime"
)
// CallQueueCap is the capacity of the call queue. This means how many calls to CallNonBlock will not
// block until some call finishes.
//
// The default value is 16 and should be good for 99% usecases.
var CallQueueCap = 16
var (
callQueue chan func()
)
func init() {
runtime.LockOSThread()
}
func checkRun() {
if callQueue == nil {
panic(errors.New("mainthread: did not call Run"))
}
}
// Run enables mainthread package functionality. To use mainthread package, put your main function
// code into the run function (the argument to Run) and simply call Run from the real main function.
//
// Run returns when run (argument) function finishes.
func Run(run func()) {
callQueue = make(chan func(), CallQueueCap)
done := make(chan struct{})
go func() {
run()
done <- struct{}{}
}()
for {
select {
case f := <-callQueue:
f()
case <-done:
return
}
}
}
// CallNonBlock queues function f on the main thread and returns immediately. Does not wait until f
// finishes.
func CallNonBlock(f func()) {
checkRun()
callQueue <- f
}
// Call queues function f on the main thread and blocks until the function f finishes.
func Call(f func()) {
checkRun()
done := make(chan struct{})
callQueue <- func() {
f()
done <- struct{}{}
}
<-done
}
// CallErr queues function f on the main thread and returns an error returned by f.
func CallErr(f func() error) error {
checkRun()
errChan := make(chan error)
callQueue <- func() {
errChan <- f()
}
return <-errChan
}
// CallVal queues function f on the main thread and returns a value returned by f.
func CallVal(f func() interface{}) interface{} {
checkRun()
respChan := make(chan interface{})
callQueue <- func() {
respChan <- f()
}
return <-respChan
}