Ignore:
Timestamp:
Dec 6, 2016, 6:28:47 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
2cd0434
Parents:
fa66f4e
Message:

cleaned-up coroutines code to no longer need a manual start

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/threads

    rfa66f4e r5c81105  
    1818#define __THREADS_H__
    1919
    20 #include <stdbool.h>
    21 
    22 extern "C" {
    23       struct coVtable {
    24             void (*main)(void*);
    25             struct coroutine* (*this_coroutine)(void*);
    26       };
    27 
    28       struct coStack_t {
    29             unsigned int size;          // size of stack
    30             void *storage;                      // pointer to stack
    31             void *limit;                        // stack grows towards stack limit
    32             void *base;                         // base of stack
    33             void *context;                      // address of cfa_context_t
    34             void *top;                          // address of top of storage
    35             bool userStack;     
    36       };
    37 
    38 
    39       enum coroutine_state { Start, Inactive, Active, Halt };
    40 
    41       struct coroutine {
    42             coStack_t stack;
    43             const char *name;                   // textual name for coroutine/task, initialized by uC++ generated code
    44             int errno_;                         // copy of global UNIX variable errno
    45             coroutine_state state;            // current execution status for coroutine
    46             bool notHalted;                     // indicate if execuation state is not halted
    47 
    48             coroutine *starter;         // first coroutine to resume this one
    49             coroutine *last;                    // last coroutine to resume this one
    50       };
    51 }
     20#include "invoke.h"
    5221
    5322void ?{}(coStack_t* this);
    5423
    5524void ?{}(coroutine* this);
     25void ?{}(coroutine* this, covptr_t* object);
    5626
    5727trait coroutine_t(dtype T) {
    58       coroutine* this_coroutine(T* this);
    5928      void co_main(T* this);
    60       coVtable* vtable(T* this);
     29      covptr_t* vtable(T* this);
    6130};
    62 
    63 forall(dtype T | coroutine_t(T))
    64 void start(T* cor);
    6531
    6632void suspend(void);
Note: See TracChangeset for help on using the changeset viewer.