- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/coroutine.c
r83a071f9 r6b0b624 1 // -*- Mode: CFA -*-2 1 // 3 2 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo … … 10 9 // Author : Thierry Delisle 11 10 // Created On : Mon Nov 28 12:27:26 2016 12 // Last Modified By : Thierry Delisle13 // Last Modified On : Mon Nov 28 12:27:26 201614 // Update Count : 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 21 22:34:57 2017 13 // Update Count : 1 15 14 // 16 15 … … 26 25 } 27 26 28 #include "kernel" 29 #include "libhdr.h" 27 #include "kernel_private.h" 30 28 31 29 #define __CFA_INVOKE_PRIVATE__ 32 30 #include "invoke.h" 33 31 34 extern volatile thread_local processor * this_processor;35 32 36 33 //----------------------------------------------------------------------------- … … 43 40 //----------------------------------------------------------------------------- 44 41 // Coroutine ctors and dtors 45 void ?{}(coStack_t &this) {46 this .size = 65000; // size of stack47 this .storage = NULL; // pointer to stack48 this .limit = NULL; // stack grows towards stack limit49 this .base = NULL; // base of stack50 this .context = NULL; // address of cfa_context_t51 this .top = NULL; // address of top of storage52 this .userStack = false;42 void ?{}(coStack_t* this) { 43 this->size = 65000; // size of stack 44 this->storage = NULL; // pointer to stack 45 this->limit = NULL; // stack grows towards stack limit 46 this->base = NULL; // base of stack 47 this->context = NULL; // address of cfa_context_t 48 this->top = NULL; // address of top of storage 49 this->userStack = false; 53 50 } 54 51 55 void ?{}(coStack_t &this, size_t size) {52 void ?{}(coStack_t* this, size_t size) { 56 53 this{}; 57 this .size = size;54 this->size = size; 58 55 59 create_stack( &this, this.size);56 create_stack(this, this->size); 60 57 } 61 58 62 void ?{}(coroutine_desc &this) {59 void ?{}(coroutine_desc* this) { 63 60 this{ "Anonymous Coroutine" }; 64 61 } 65 62 66 void ?{}(coroutine_desc &this, const char * name) {67 this .name = name;68 this .errno_ = 0;69 this .state = Start;70 this .starter = NULL;71 this .last = NULL;63 void ?{}(coroutine_desc* this, const char * name) { 64 this->name = name; 65 this->errno_ = 0; 66 this->state = Start; 67 this->starter = NULL; 68 this->last = NULL; 72 69 } 73 70 74 void ?{}(coroutine_desc &this, size_t size) {71 void ?{}(coroutine_desc* this, size_t size) { 75 72 this{}; 76 ( this.stack){size};73 (&this->stack){size}; 77 74 } 78 75 79 void ^?{}(coStack_t &this) {80 if ( ! this .userStack ) {76 void ^?{}(coStack_t* this) { 77 if ( ! this->userStack ) { 81 78 LIB_DEBUG_DO( 82 if ( mprotect( this .storage, pageSize, PROT_READ | PROT_WRITE ) == -1 ) {83 abortf( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) );79 if ( mprotect( this->storage, pageSize, PROT_READ | PROT_WRITE ) == -1 ) { 80 abortf( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", this, errno, strerror( errno ) ); 84 81 } 85 82 ); 86 free( this .storage );83 free( this->storage ); 87 84 } 88 85 } 89 86 90 void ^?{}(coroutine_desc &this) {}87 void ^?{}(coroutine_desc* this) {} 91 88 92 89 // Part of the Public API 93 90 // Not inline since only ever called once per coroutine 94 91 forall(dtype T | is_coroutine(T)) 95 void prime(T &cor) {92 void prime(T* cor) { 96 93 coroutine_desc* this = get_coroutine(cor); 97 94 assert(this->state == Start);
Note:
See TracChangeset
for help on using the changeset viewer.