Ignore:
File:
1 edited

Legend:

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

    rab5baab re84ab3d  
    2020
    2121#ifdef __cforall
     22#include "containers/list.hfa"
    2223extern "C" {
    2324#endif
     
    7071        enum __Coroutine_State { Halted, Start, Primed, Blocked, Ready, Active, Cancelled, Halting };
    7172
    72         struct $coroutine {
     73        struct coroutine$ {
    7374                // context that is switch during a __cfactx_switch
    7475                struct __stack_context_t context;
     
    8485
    8586                // first coroutine to resume this one
    86                 struct $coroutine * starter;
     87                struct coroutine$ * starter;
    8788
    8889                // last coroutine to resume this one
    89                 struct $coroutine * last;
     90                struct coroutine$ * last;
    9091
    9192                // If non-null stack must be unwound with this exception
     
    9495        };
    9596        // Wrapper for gdb
    96         struct cfathread_coroutine_t { struct $coroutine debug; };
    97 
    98         static inline struct __stack_t * __get_stack( struct $coroutine * cor ) {
     97        struct cfathread_coroutine_t { struct coroutine$ debug; };
     98
     99        static inline struct __stack_t * __get_stack( struct coroutine$ * cor ) {
    99100                return (struct __stack_t*)(((uintptr_t)cor->stack.storage) & ((uintptr_t)-2));
    100101        }
     
    109110        };
    110111
    111         struct $monitor {
     112        struct monitor$ {
    112113                // spinlock to protect internal data
    113114                struct __spinlock_t lock;
    114115
    115116                // current owner of the monitor
    116                 struct $thread * owner;
     117                struct thread$ * owner;
    117118
    118119                // queue of threads that are blocked waiting for the monitor
    119                 __queue_t(struct $thread) entry_queue;
     120                __queue_t(struct thread$) entry_queue;
    120121
    121122                // stack of conditions to run next once we exit the monitor
     
    132133        };
    133134        // Wrapper for gdb
    134         struct cfathread_monitor_t { struct $monitor debug; };
     135        struct cfathread_monitor_t { struct monitor$ debug; };
    135136
    136137        struct __monitor_group_t {
    137138                // currently held monitors
    138                 __cfa_anonymous_object( __small_array_t($monitor*) );
     139                __cfa_anonymous_object( __small_array_t(monitor$*) );
    139140
    140141                // last function that acquired monitors
     
    145146        // instrusive link field for threads
    146147        struct __thread_desc_link {
    147                 struct $thread * next;
     148                struct thread$ * next;
    148149                volatile unsigned long long ts;
    149150        };
    150151
    151         struct $thread {
     152        struct thread$ {
    152153                // Core threading fields
    153154                // context that is switch during a __cfactx_switch
     
    178179
    179180                // coroutine body used to store context
    180                 struct $coroutine  self_cor;
     181                struct coroutine$  self_cor;
    181182
    182183                // current active context
    183                 struct $coroutine * curr_cor;
     184                struct coroutine$ * curr_cor;
    184185
    185186                // monitor body used for mutual exclusion
    186                 struct $monitor    self_mon;
     187                struct monitor$    self_mon;
    187188
    188189                // pointer to monitor with sufficient lifetime for current monitors
    189                 struct $monitor *  self_mon_p;
     190                struct monitor$ *  self_mon_p;
    190191
    191192                // monitors currently held by this thread
     
    194195                // used to put threads on user data structures
    195196                struct {
    196                         struct $thread * next;
    197                         struct $thread * back;
     197                        struct thread$ * next;
     198                        struct thread$ * back;
    198199                } seqable;
    199200
     201                // used to put threads on dlist data structure
     202                __cfa_dlink(thread$);
     203
    200204                struct {
    201                         struct $thread * next;
    202                         struct $thread * prev;
     205                        struct thread$ * next;
     206                        struct thread$ * prev;
    203207                } node;
    204208
     
    209213                #endif
    210214        };
     215        #ifdef __cforall
     216                P9_EMBEDDED( thread$, dlink(thread$) )
     217        #endif
    211218        // Wrapper for gdb
    212         struct cfathread_thread_t { struct $thread debug; };
     219        struct cfathread_thread_t { struct thread$ debug; };
    213220
    214221        #ifdef __CFA_DEBUG__
    215                 void __cfaabi_dbg_record_thrd($thread & this, bool park, const char prev_name[]);
     222                void __cfaabi_dbg_record_thrd(thread$ & this, bool park, const char prev_name[]);
    216223        #else
    217224                #define __cfaabi_dbg_record_thrd(x, y, z)
     
    221228        extern "Cforall" {
    222229
    223                 static inline $thread *& get_next( $thread & this ) __attribute__((const)) {
     230                static inline thread$ *& get_next( thread$ & this ) __attribute__((const)) {
    224231                        return this.link.next;
    225232                }
    226233
    227                 static inline [$thread *&, $thread *& ] __get( $thread & this ) __attribute__((const)) {
     234                static inline [thread$ *&, thread$ *& ] __get( thread$ & this ) __attribute__((const)) {
    228235                        return this.node.[next, prev];
    229236                }
    230237
    231                 static inline $thread * volatile & ?`next ( $thread * this )  __attribute__((const)) {
     238                static inline thread$ * volatile & ?`next ( thread$ * this )  __attribute__((const)) {
    232239                        return this->seqable.next;
    233240                }
    234241
    235                 static inline $thread *& Back( $thread * this ) __attribute__((const)) {
     242                static inline thread$ *& Back( thread$ * this ) __attribute__((const)) {
    236243                        return this->seqable.back;
    237244                }
    238245
    239                 static inline $thread *& Next( $thread * this ) __attribute__((const)) {
    240                         return this->seqable.next;
    241                 }
    242 
    243                 static inline bool listed( $thread * this ) {
     246                static inline thread$ *& Next( thread$ * this ) __attribute__((const)) {
     247                                return this->seqable.next;
     248                }
     249
     250                static inline bool listed( thread$ * this ) {
    244251                        return this->seqable.next != 0p;
    245252                }
     
    251258                }
    252259
    253                 static inline void ?{}(__monitor_group_t & this, struct $monitor ** data, __lock_size_t size, fptr_t func) {
     260                static inline void ?{}(__monitor_group_t & this, struct monitor$ ** data, __lock_size_t size, fptr_t func) {
    254261                        (this.data){data};
    255262                        (this.size){size};
Note: See TracChangeset for help on using the changeset viewer.