Skip to content

Array-port based WaitGroup #890

@emil14

Description

@emil14

Problem

Existing sync.WaitGroup signature looks like this

def WaitGroup(count int, sig any) (sig any)

It can cover complex cases where number of tasks is unknown at compile-time, but in most cases we know that, so it's an overkill. Array-port based interface would be simpler to use:

def WaitGroup([sig] any) (sig any)

Example - Indeterministic "Hello World"

What we have

import { fmt, sync }

def Main(start any) (stop any) {
    println1 fmt.Println
	println2 fmt.Println
	wg sync.WaitGroup
    ---
    :start -> [
		'Hello' -> println1,
		', World!' -> println2
	]
    [println1, println2] -> wg:sig
    2 -> wg:count
    wg -> :stop
}

What we need

import { fmt, sync }

def Main(start any) (stop any) {
	println1 fmt.Println
	println2 fmt.Println
	wg sync.WaitGroup
	---
	:start -> [
		'Hello' -> println1 -> wg[0],
		', World!' -> println2 -> wg[1]
	]
	wg -> :stop
}

Solution

  • Rename existing sync.WaitGroup to something else (figure out good naming)
  • Change sync.WaitGroup interface to array-port based
  • Update related examples and/or e2e tests and docs (if needed)

Related to #864

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions