Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

several suggestions #8

Open
ggaaooppeenngg opened this issue Dec 20, 2014 · 1 comment
Open

several suggestions #8

ggaaooppeenngg opened this issue Dec 20, 2014 · 1 comment

Comments

@ggaaooppeenngg
Copy link

I browsed your code and have some suggestions.

first, I think underscore need a more general function instead of specifying a function for a certain type,for instance in order to map string you need to specify a SMap function pointer.Your code was excellent,could be there any way to implement such general function? such like not returning []interface{},but receive a point of return value as argument,in order to reflect the result.

second, in Each, I think sync.WaitGroup is more comlicated because it is implemented by lock,and why not do like


var done = make(chan struct{}{},m.Len()) //m is the map or slice
for i:= 0;i<s.Len();i++{
    go func(){
        donw <-
    }() 
}

for i:= 0;i<s.Len();i++{
    done <-
}

I thins this dose the same work,but in more Go way.

third, function decleration is not constant,Each has argument name but Map does not which will make some confusion.

fourth chan argument should be more strict ,to spefigy read-only or write-only
reader need argument like job <- chan,which should only read from in the function body.

fifth , jobs in Each should be bufferd capabible of len of workers number,
so that workers will not block on read or write and will be more akin parallel

That's my thoughts,maybe it's wrong or not appropriate,hoping to discuss!

@elgs
Copy link

elgs commented Jan 18, 2016

Shouldn't the index of the array be passed in the Map's callback function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants