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