Esempio n. 1
0
TEST(Fibonacci, ComputesFibonacciSequence) {
    FiberSystem system;
    system.fiberize();

    auto fibonacciPar = system.future(fibonacciFuture);
    for (int i = 0; i < 100; ++i) {
        for (uint64_t n = 0; n <= 20; ++n) {
            EXPECT_EQ(fibonacci(n), fibonacciPar.copy().run(n).await().get());
        }
    }
}
Esempio n. 2
0
int main() {
    FiberSystem system;
    AnyFiberRef self = system.fiberize();
    system.subscribe(self);

    for (size_t i = 0; i < spawners; ++i) {
        system.run<Spawner>();
    }

    system.allFibersFinished().await();
    return 0;
}
Esempio n. 3
0
void Builder<TaskTraits, Entity, MailboxType>::run_(Args&&... args) {
    using Traits = TraitsFor<Args...>;
    assert(!invalidated);
    invalidated = true;

    FiberSystem* system = Scheduler::current()->system();
    if (!system->shuttingDown()) {
        /**
         * Create and schedule the task
         */
        Path path = PrefixedPath(system->uuid(), ident());
        std::unique_ptr<Mailbox> mailbox(new MailboxType(std::move(mailbox_)));
        auto task = Traits::newTask(std::move(path), std::move(mailbox), pin_,
            detail::bind<Entity, Args...>(std::move(task_), std::forward<Args>(args)...));
        runner_(task);
    }
}