Documentation ¶
Overview ¶
Copyright 2017 Albert Tedja Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package mputil contains useful helpers for converting multi-processor computation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Lock ¶ added in v1.0.0
type Lock struct {
// contains filtered or unexported fields
}
func NewMultilock ¶ added in v1.0.0
Creates a new multilock for the specified keys
type WorkerResults ¶
type WorkerResults struct { Offset int Extent interface{} }
WorkerResults are the results of a scatter worker.
func Scatter ¶
func Scatter(inputLen int, sFunc func(int, int, *sync.RWMutex) (interface{}, error)) ([]*WorkerResults, error)
Scatter scatters a computation across multiple goroutines. This breaks the task in to a number of chunks and executes those chunks in parallel with the function provided. Results returned are collected and presented a a set of WorkerResults, which can be reassembled by the calling function. Any error that occurs in the workers will be passed back to the calling function.