view src/examples/boundedBuffer/producer.cbc @ 590:9146d6017f18 default tip

hg mv parallel_execution/* ..
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Thu, 16 Jan 2020 15:12:06 +0900
parents src/parallel_execution/examples/boundedBuffer/producer.cbc@62166b0e0c7e
children
line wrap: on
line source

#include "../../../context.h"
#interface "Buffer.h"

__code producer(struct Buffer* buffer, struct Integer* length, __code next(...), struct LoopCounter* loopCounter) {
    int i = loopCounter->i;
    if (i < length->value) {
        Node* node = new Node();
        node->value = (union Data*)new Integer();
        node->value->Integer.value = i;
        loopCounter->i++;
        goto buffer->put(node, producer);
    }
    goto next(...);
}