Skip to content

Nice way to run on specific queues #1

@ide

Description

@ide

One of the things that Bolts does pretty well is let you choose a queue to run a block on, while this is manual with PromiseKit. I think it'd be useful to be able to write:

dispatch_queue_t queue = ...;
dispatch_promise(queue, ^{
    return [self makeValueAsync];
}).then(dispatch_get_main_queue(), ^(id value) {
    [self.view displayValue:value];
    return [self logDisplayInfo:self.view];
}).then(^{
    // No queue specified: synchronously run on the same queue immediately after
    // logDisplayInfo's promise is resolved
});

Also Bolts has an "executor" abstraction that runs blocks. Executors might be more general than needed but the default executors are useful to have:

  • dispatch_async to the main queue
  • dispatch_async to the default-pri background queue
  • run synchronously on the current queue where the previous task finished

Metadata

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