diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-05-12 15:08:58 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-05-12 16:37:29 -0400 |
commit | 84d2482ddbff9564c9ad75b2d30af66e3ddfd44d (patch) | |
tree | 8bfa567d2b6381f4a996ada2deff8a16aa85a3ac /Godeps/_workspace/src/github.com/disintegration/imaging/utils.go | |
parent | d1efb66ad7b017f0fbfe6f0c20843b30f396e504 (diff) | |
download | chat-84d2482ddbff9564c9ad75b2d30af66e3ddfd44d.tar.gz chat-84d2482ddbff9564c9ad75b2d30af66e3ddfd44d.tar.bz2 chat-84d2482ddbff9564c9ad75b2d30af66e3ddfd44d.zip |
Updating go depencancies. Switching to go1.6 vendoring (#2949)
Diffstat (limited to 'Godeps/_workspace/src/github.com/disintegration/imaging/utils.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/disintegration/imaging/utils.go | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/Godeps/_workspace/src/github.com/disintegration/imaging/utils.go b/Godeps/_workspace/src/github.com/disintegration/imaging/utils.go deleted file mode 100644 index 8b1ab8adb..000000000 --- a/Godeps/_workspace/src/github.com/disintegration/imaging/utils.go +++ /dev/null @@ -1,77 +0,0 @@ -package imaging - -import ( - "math" - "runtime" - "sync" - "sync/atomic" -) - -var parallelizationEnabled = true - -// if GOMAXPROCS = 1: no goroutines used -// if GOMAXPROCS > 1: spawn N=GOMAXPROCS workers in separate goroutines -func parallel(dataSize int, fn func(partStart, partEnd int)) { - numGoroutines := 1 - partSize := dataSize - - if parallelizationEnabled { - numProcs := runtime.GOMAXPROCS(0) - if numProcs > 1 { - numGoroutines = numProcs - partSize = dataSize / (numGoroutines * 10) - if partSize < 1 { - partSize = 1 - } - } - } - - if numGoroutines == 1 { - fn(0, dataSize) - } else { - var wg sync.WaitGroup - wg.Add(numGoroutines) - idx := uint64(0) - - for p := 0; p < numGoroutines; p++ { - go func() { - defer wg.Done() - for { - partStart := int(atomic.AddUint64(&idx, uint64(partSize))) - partSize - if partStart >= dataSize { - break - } - partEnd := partStart + partSize - if partEnd > dataSize { - partEnd = dataSize - } - fn(partStart, partEnd) - } - }() - } - - wg.Wait() - } -} - -func absint(i int) int { - if i < 0 { - return -i - } - return i -} - -// clamp & round float64 to uint8 (0..255) -func clamp(v float64) uint8 { - return uint8(math.Min(math.Max(v, 0.0), 255.0) + 0.5) -} - -// clamp int32 to uint8 (0..255) -func clampint32(v int32) uint8 { - if v < 0 { - return 0 - } else if v > 255 { - return 255 - } - return uint8(v) -} |