Ignore:
Timestamp:
Dec 7, 2016, 2:47:53 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:
550a3385
Parents:
a68caae
Message:

Coroutines no longer require virtual pointers or any code beyond the get_coroutine routine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/invoke.h

    ra68caae r80d9e49  
    1010#define _INVOKE_H_
    1111
    12       #define OFFSET_OF(type, field) ((intptr_t)( &((type*)0)->field))
    13       #define VPTR_OFFSET(type, vptr, field) (OFFSET_OF(type, field) - OFFSET_OF(type, vptr))
    14 
    15       struct coVtable_t {
    16             void (*main)(void*);
    17             intptr_t offset_coroutine;
    18             intptr_t offset_object;
    19       };
    20 
    21       typedef struct coVtable_t* covptr_t;
    22 
    23       static inline struct coroutine* get_coroutine(covptr_t* vthis) {
    24             return (struct coroutine*) ( ((intptr_t)vthis) + ((intptr_t)(*vthis)->offset_coroutine) );
    25       }
    26 
    27       static inline void* get_object(covptr_t* vthis) {
    28             return (void*) ( ((intptr_t)vthis) + ((intptr_t)(*vthis)->offset_object) );
    29       }
    30 
    31       struct coStack_t {
     12     struct coStack_t {
    3213            unsigned int size;          // size of stack
    3314            void *storage;                      // pointer to stack
     
    3920      };
    4021
    41       enum coroutine_state { Start, Inactive, Active, Halt };
     22      enum coroutine_state { Start, Inactive, Active, Halt, Primed };
    4223
    4324      struct coroutine {
     
    5233      };
    5334
    54       void invokeCoroutine(covptr_t* this);
    55       void startCoroutine(covptr_t* this, void (*invoke)(covptr_t*));
    5635#endif //_INVOKE_H_
    5736#else //! defined(__CFA_INVOKE_PRIVATE__)
Note: See TracChangeset for help on using the changeset viewer.