Ignore:
Timestamp:
Jan 17, 2017, 5:13:47 PM (7 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:
c49bf54
Parents:
7350ff97
Message:

First prototype of cfa threads running (1 thread on 1 processor)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/coroutines

    r7350ff97 r8118303  
    1 //                              -*- Mode: CFA -*-
     1//                              - *- Mode: CFA - *-
    22//
    33// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    1818#define COROUTINES_H
    1919
    20 #include "assert"       //
     20#include "assert"
    2121#include "invoke.h"
    2222
     
    2626// Anything that is resumed is a coroutine.
    2727trait is_coroutine(dtype T) {
    28       void co_main(T* this);
    29       coroutine* get_coroutine(T* this);
     28      void co_main(T * this);
     29      coroutine * get_coroutine(T * this);
    3030};
    3131
    3232//-----------------------------------------------------------------------------
    3333// Ctors and dtors
    34 void ?{}(coStack_t* this);
    35 void ?{}(coroutine* this);
    36 void ^?{}(coStack_t* this);
    37 void ^?{}(coroutine* this);
     34void ?{}(coStack_t * this);
     35void ?{}(coroutine * this);
     36void ^?{}(coStack_t * this);
     37void ^?{}(coroutine * this);
    3838
    3939//-----------------------------------------------------------------------------
     
    4242
    4343forall(dtype T | is_coroutine(T))
    44 static inline void resume(T* cor);
     44static inline void resume(T * cor);
    4545
    4646forall(dtype T | is_coroutine(T))
    47 void prime(T* cor);
     47void prime(T * cor);
    4848
    4949//-----------------------------------------------------------------------------
     
    5353extern "C" {
    5454      forall(dtype T | is_coroutine(T))
    55       void CtxInvokeCoroutine(T* this);
     55      void CtxInvokeCoroutine(T * this);
    5656
    5757      forall(dtype T | is_coroutine(T))
    58       void CtxStart(T* this, void (*invoke)(T*));
     58      void CtxStart(T * this, void ( *invoke)(T *));
    5959}
    6060
    6161// Get current coroutine
    62 extern coroutine* current_coroutine; //PRIVATE, never use directly
    63 static inline coroutine* this_coroutine(void) {
     62extern coroutine * current_coroutine; //PRIVATE, never use directly
     63static inline coroutine * this_coroutine(void) {
    6464        return current_coroutine;
    6565}
    6666
    6767// Private wrappers for context switch and stack creation
    68 extern void corCxtSw(coroutine* src, coroutine* dst);
    69 extern void create_stack( coStack_t* this, unsigned int storageSize );
     68extern void corCxtSw(coroutine * src, coroutine * dst);
     69extern void create_stack( coStack_t * this, unsigned int storageSize );
    7070
    7171// Suspend implementation inlined for performance
    7272static inline void suspend() {
    73       coroutine* src = this_coroutine();                // optimization
     73      coroutine * src = this_coroutine();               // optimization
    7474
    7575        assertf( src->last != 0,
     
    8787// Resume implementation inlined for performance
    8888forall(dtype T | is_coroutine(T))
    89 static inline void resume(T* cor) {
    90         coroutine* src = this_coroutine();              // optimization
    91         coroutine* dst = get_coroutine(cor);
     89static inline void resume(T * cor) {
     90        coroutine * src = this_coroutine();             // optimization
     91        coroutine * dst = get_coroutine(cor);
    9292
    9393      if( unlikely(!dst->stack.base) ) {
Note: See TracChangeset for help on using the changeset viewer.