Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bastion::spawn method #122

Merged
merged 2 commits into from
Dec 11, 2019
Merged

Add Bastion::spawn method #122

merged 2 commits into from
Dec 11, 2019

Conversation

Stupremee
Copy link
Member

@Stupremee Stupremee commented Dec 11, 2019

This Pull Request adds a method to quickly create a children with a given action without having to
use the closure in Bastion::children.

Checklist

  • tests are passing with cargo test.
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message is clear

Example

use bastion::prelude::*;

fn main() {
    Bastion::init();
    
    let children_ref: ChildrenRef = Bastion::spawn(|ctx: BastionContext| {
        async move {
            // ...
            Ok(())
        }
    }).expect("Couldn't create the children group.");
    Bastion::start();
    Bastion::stop();
    Bastion::block_until_stopped();
 }

This change was requested in #116

Copy link
Member

@vertexclique vertexclique left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, welcome to the Bastion 🏰 !
Second, looks good :shipit:

@vertexclique vertexclique merged commit 03fef49 into bastion-rs:master Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants