chrislusf / glow

Glow is an easy-to-use distributed computation system written in Go, similar to Hadoop Map Reduce, Spark, Flink, Storm, etc. I am also working on another similar pure Go system, https://github.com/chrislusf/gleam , which is more flexible and more performant.
3.2k stars 248 forks source link

clean up sync.Mutex usage #7

Closed chrislusf closed 8 years ago

chrislusf commented 8 years ago

Need cleaner code.

monkeybutter commented 8 years ago

I've done a test changing a couple of structs. Basically when the struct contains a lock for itself lock is declared as anonymous field. When the struct contains an field that is lockable that field is declared as a lockable struct outside and embedded in the first one.

An example can be seen at:

https://github.com/monkeybutter/glow/commit/caa111b8ce1fb837917f4b1fcd9c49450167c52d

I haven't tested the code and I don't know how these changes would affect other functions using these structs outside the files where they've been declared. This is only an example to ask for feedback about the proposal.

chrislusf commented 8 years ago

Nice to learn this technique!

You can test by running the examples in both standalone mode and distributed mode.

Chris

On Wednesday, October 28, 2015, Pablo Rozas-Larraondo < notifications@github.com> wrote:

I've done a test changing a couple of structs. Basically when the struct contains a lock for itself lock is declared as anonymous field. When the struct contains an field that is lockable that field is declared as a lockable struct outside and embedded in the first one.

An example can be seen at:

monkeybutter@caa111b https://github.com/monkeybutter/glow/commit/caa111b8ce1fb837917f4b1fcd9c49450167c52d

I haven't tested the code and I don't know how these changes would affect other functions using these structs outside the files where they've been declared. This is only an example to ask for feedback about the proposal.

— Reply to this email directly or view it on GitHub https://github.com/chrislusf/glow/issues/7#issuecomment-152021515.