Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Combined operator<<() isn't thread safe if used outside main thread #34

Open
@vpicaver

Description

An example of this issue is if two futures being added to Combined(). If future1 finished before future2 has been added, this will complete() the Combined(). Even though in this use case, we want the code below to print out "Finished!" once both future1 and future2 are finished. If future1 is finished before future2 is added, Finished() will be prematurely, called.

auto combine = Combined() << future1 << future2;
combine.subscribe([]() { qDebug() << "Finished!"; }

I don't think this can be easily be fixed without api changes to how Combine() is handled. Perhaps it better to advocate using async on the main thread only. The deferred needs to have a proper context object to make this work correrctly. By default deferred is move to the main thread.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions