async icon indicating copy to clipboard operation
async copied to clipboard

Why not support non-empty arguments function with Concurrent or Parallel?

Open woofyzhao opened this issue 6 years ago • 5 comments

woofyzhao avatar Apr 05 '19 09:04 woofyzhao

Are you receiving any error while using non-empty arguments function with Concurrent or Parallel? Can you show us any example of what you are trying to do?

rafaeldias avatar Apr 18 '19 15:04 rafaeldias

Are you receiving any error while using non-empty arguments function with Concurrent or Parallel? Can you show us any example of what you are trying to do?

Hi, it seems that concurrent/parallel API don't support pass parameters

func execRoutine(f reflect.Value, c chan execResult, key string) { var ( exr = execResult{} // Result res = f.Call(emptyArgs) // Calls the function )

Routine call function with emptyArgs in func.go

hawkinggg avatar Nov 28 '19 01:11 hawkinggg

@hawkinggg I see. When writing those functions three years ago I thought of Parallel and Concurrent functions receiving an optional list of parameters as last argument that would be passed to every function passed to them, but at the time I had no use for this case.

Maybe a modification like:

async.Concurrent(async.Tasks{
        func(i int, s string, b bool) error { ... },
        func(i int, s string, b bool) error { ... },
        func(i int, s string, b bool) error { ... },
}, 1, "test", false)

Could solve the problem without breaking the current usage of the package.

rafaeldias avatar Nov 28 '19 02:11 rafaeldias

@rafaeldias

Hi, 4 years later, I see that this library has a lot of potential. Can you make me as the contributor to this library? I will resolve those 2 issues.

MrNocTV avatar Mar 10 '23 03:03 MrNocTV

@MrNocTV I believe, you may start with creating pull requests to resolve those issues without becoming a contributor, by just forking it and making a PR from your fork. Additionally, if the maintainer of this library won't have time for the job, community we'll be able to continue to live with the fork

SealOfTime avatar Mar 26 '23 12:03 SealOfTime