Changeset d3e4d6c for src/libcfa/concurrency/coroutine.c
- Timestamp:
- Aug 23, 2017, 6:22:07 PM (8 years ago)
- 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:
- 87e08e24, cb811ac
- Parents:
- 9f07232 (diff), bd37119 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/coroutine.c
r9f07232 rd3e4d6c 40 40 //----------------------------------------------------------------------------- 41 41 // 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;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; 50 50 } 51 51 52 void ?{}(coStack_t *this, size_t size) {52 void ?{}(coStack_t& this, size_t size) { 53 53 this{}; 54 this ->size = size;54 this.size = size; 55 55 56 create_stack( this, this->size);56 create_stack(&this, this.size); 57 57 } 58 58 59 void ?{}(coroutine_desc *this) {59 void ?{}(coroutine_desc& this) { 60 60 this{ "Anonymous Coroutine" }; 61 61 } 62 62 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;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; 69 69 } 70 70 71 void ?{}(coroutine_desc *this, size_t size) {71 void ?{}(coroutine_desc& this, size_t size) { 72 72 this{}; 73 ( &this->stack){size};73 (this.stack){size}; 74 74 } 75 75 76 void ^?{}(coStack_t *this) {77 if ( ! this ->userStack ) {76 void ^?{}(coStack_t& this) { 77 if ( ! this.userStack ) { 78 78 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 ) );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 ) ); 81 81 } 82 82 ); 83 free( this ->storage );83 free( this.storage ); 84 84 } 85 85 } 86 86 87 void ^?{}(coroutine_desc *this) {}87 void ^?{}(coroutine_desc& this) {} 88 88 89 89 // Part of the Public API 90 90 // Not inline since only ever called once per coroutine 91 91 forall(dtype T | is_coroutine(T)) 92 void prime(T *cor) {92 void prime(T& cor) { 93 93 coroutine_desc* this = get_coroutine(cor); 94 94 assert(this->state == Start);
Note:
See TracChangeset
for help on using the changeset viewer.