Go - Concurrent method
Posted
by nevalu
on Stack Overflow
See other posts from Stack Overflow
or by nevalu
Published on 2010-05-05T09:33:03Z
Indexed on
2010/05/05
9:38 UTC
Read the original article
Hit count: 206
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?
© Stack Overflow or respective owner