Skip to content

FlatMap seems not parallelly WithPool or WithCPUPool #273

@arlor

Description

@arlor

FlatMap not run parallelly WithPool or WithCPUPool

See:

package main

import (
        "fmt"
        "time"

        "github.com/reactivex/rxgo/v2"
)

func main() {
        obs := rxgo.Just(1, 2, 3)().FlatMap(
                func(i rxgo.Item) rxgo.Observable {
                        time.Sleep(time.Second)
                        return rxgo.Just(i.V.(int)*10, i.V.(int)*100)()
                },
                rxgo.WithCPUPool(),
        )

        start := time.Now().Unix()
        for item := range obs.Observe() {
                fmt.Printf("item: %+v\n", item)
        }
        end := time.Now().Unix()
        fmt.Printf("cost: %d seconds\n", end-start)
}

Expect:
cost 1 seconds

Actual:
cost 3 seconds

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions