Go - Concurrent method
- by nevalu
How to get a concurrent method?
In my case, the library would be called from a program to get a value to each argument str --in method Get()--.
When it's used Get() then it assigns a variable from type bytes.Buffer which it will have the value to return.
The returned values --when it been concurrently called-- will be stored into a database or a file and it doesn't matter that its output been of FIFO way (from method).
type test struct {
foo uint8
bar uint8
}
func NewTest(arg1 string) (*test, os.Error) {...}
func (self *test) Get(str string) ([]byte, os.Error) {
var format bytes.Buffer
...
}
I think that all code inner of method Get() should be put inner of go func() {...}(), and then to use a channel.
Would there be a problem if it's called another method from Get()? Or would it also has to be concurrent?