Skip to content

Async tasks -- move start to the end of the blocking call #5562

@jisantuc

Description

@jisantuc

Problem description

We have to explicitly pass context shifts to the things we want to do in the background, like:

taskGridBlocker
                .blockOn(
                  TaskDao
                    .insertTasksByGrid(
                      Task
                        .TaskPropertiesCreate(
                          TaskStatus.Unlabeled,
                          projectId,
                          None,
                          None,
                          None,
                          None
                        ),
                      tgf,
                      user
                    )
                    .transact(xa)
                    .start(taskGridContextShift)
                )(taskGridContextShift)

I think we could instead do something like:

taskGridBlocker
                .blockOn(
                  TaskDao
                    .insertTasksByGrid(
                      Task
                        .TaskPropertiesCreate(
                          TaskStatus.Unlabeled,
                          projectId,
                          None,
                          None,
                          None,
                          None
                        ),
                      tgf,
                      user
                    )
                    .transact(xa)
                )(taskGridContextShift).start

I believe that this should preserve the "ship it to the background" behavior while requiring fewer edits in the future -- you only have to remember to change one explicit context shift instead of two. We have this in a few places and are adding another in #5559

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