Ignore:
File:
1 edited

Legend:

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

    re84ab3d rab5baab  
    2020
    2121#ifdef __cforall
    22 #include "containers/list.hfa"
    2322extern "C" {
    2423#endif
     
    7170        enum __Coroutine_State { Halted, Start, Primed, Blocked, Ready, Active, Cancelled, Halting };
    7271
    73         struct coroutine$ {
     72        struct $coroutine {
    7473                // context that is switch during a __cfactx_switch
    7574                struct __stack_context_t context;
     
    8584
    8685                // first coroutine to resume this one
    87                 struct coroutine$ * starter;
     86                struct $coroutine * starter;
    8887
    8988                // last coroutine to resume this one
    90                 struct coroutine$ * last;
     89                struct $coroutine * last;
    9190
    9291                // If non-null stack must be unwound with this exception
     
    9594        };
    9695        // Wrapper for gdb
    97         struct cfathread_coroutine_t { struct coroutine$ debug; };
    98 
    99         static inline struct __stack_t * __get_stack( struct coroutine$ * cor ) {
     96        struct cfathread_coroutine_t { struct $coroutine debug; };
     97
     98        static inline struct __stack_t * __get_stack( struct $coroutine * cor ) {
    10099                return (struct __stack_t*)(((uintptr_t)cor->stack.storage) & ((uintptr_t)-2));
    101100        }
     
    110109        };
    111110
    112         struct monitor$ {
     111        struct $monitor {
    113112                // spinlock to protect internal data
    114113                struct __spinlock_t lock;
    115114
    116115                // current owner of the monitor
    117                 struct thread$ * owner;
     116                struct $thread * owner;
    118117
    119118                // queue of threads that are blocked waiting for the monitor
    120                 __queue_t(struct thread$) entry_queue;
     119                __queue_t(struct $thread) entry_queue;
    121120
    122121                // stack of conditions to run next once we exit the monitor
     
    133132        };
    134133        // Wrapper for gdb
    135         struct cfathread_monitor_t { struct monitor$ debug; };
     134        struct cfathread_monitor_t { struct $monitor debug; };
    136135
    137136        struct __monitor_group_t {
    138137                // currently held monitors
    139                 __cfa_anonymous_object( __small_array_t(monitor$*) );
     138                __cfa_anonymous_object( __small_array_t($monitor*) );
    140139
    141140                // last function that acquired monitors
     
    146145        // instrusive link field for threads
    147146        struct __thread_desc_link {
    148                 struct thread$ * next;
     147                struct $thread * next;
    149148                volatile unsigned long long ts;
    150149        };
    151150
    152         struct thread$ {
     151        struct $thread {
    153152                // Core threading fields
    154153                // context that is switch during a __cfactx_switch
     
    179178
    180179                // coroutine body used to store context
    181                 struct coroutine$  self_cor;
     180                struct $coroutine  self_cor;
    182181
    183182                // current active context
    184                 struct coroutine$ * curr_cor;
     183                struct $coroutine * curr_cor;
    185184
    186185                // monitor body used for mutual exclusion
    187                 struct monitor$    self_mon;
     186                struct $monitor    self_mon;
    188187
    189188                // pointer to monitor with sufficient lifetime for current monitors
    190                 struct monitor$ *  self_mon_p;
     189                struct $monitor *  self_mon_p;
    191190
    192191                // monitors currently held by this thread
     
    195194                // used to put threads on user data structures
    196195                struct {
    197                         struct thread$ * next;
    198                         struct thread$ * back;
     196                        struct $thread * next;
     197                        struct $thread * back;
    199198                } seqable;
    200199
    201                 // used to put threads on dlist data structure
    202                 __cfa_dlink(thread$);
    203 
    204200                struct {
    205                         struct thread$ * next;
    206                         struct thread$ * prev;
     201                        struct $thread * next;
     202                        struct $thread * prev;
    207203                } node;
    208204
     
    213209                #endif
    214210        };
    215         #ifdef __cforall
    216                 P9_EMBEDDED( thread$, dlink(thread$) )
    217         #endif
    218211        // Wrapper for gdb
    219         struct cfathread_thread_t { struct thread$ debug; };
     212        struct cfathread_thread_t { struct $thread debug; };
    220213
    221214        #ifdef __CFA_DEBUG__
    222                 void __cfaabi_dbg_record_thrd(thread$ & this, bool park, const char prev_name[]);
     215                void __cfaabi_dbg_record_thrd($thread & this, bool park, const char prev_name[]);
    223216        #else
    224217                #define __cfaabi_dbg_record_thrd(x, y, z)
     
    228221        extern "Cforall" {
    229222
    230                 static inline thread$ *& get_next( thread$ & this ) __attribute__((const)) {
     223                static inline $thread *& get_next( $thread & this ) __attribute__((const)) {
    231224                        return this.link.next;
    232225                }
    233226
    234                 static inline [thread$ *&, thread$ *& ] __get( thread$ & this ) __attribute__((const)) {
     227                static inline [$thread *&, $thread *& ] __get( $thread & this ) __attribute__((const)) {
    235228                        return this.node.[next, prev];
    236229                }
    237230
    238                 static inline thread$ * volatile & ?`next ( thread$ * this )  __attribute__((const)) {
     231                static inline $thread * volatile & ?`next ( $thread * this )  __attribute__((const)) {
    239232                        return this->seqable.next;
    240233                }
    241234
    242                 static inline thread$ *& Back( thread$ * this ) __attribute__((const)) {
     235                static inline $thread *& Back( $thread * this ) __attribute__((const)) {
    243236                        return this->seqable.back;
    244237                }
    245238
    246                 static inline thread$ *& Next( thread$ * this ) __attribute__((const)) {
    247                                 return this->seqable.next;
    248                 }
    249 
    250                 static inline bool listed( thread$ * this ) {
     239                static inline $thread *& Next( $thread * this ) __attribute__((const)) {
     240                        return this->seqable.next;
     241                }
     242
     243                static inline bool listed( $thread * this ) {
    251244                        return this->seqable.next != 0p;
    252245                }
     
    258251                }
    259252
    260                 static inline void ?{}(__monitor_group_t & this, struct monitor$ ** data, __lock_size_t size, fptr_t func) {
     253                static inline void ?{}(__monitor_group_t & this, struct $monitor ** data, __lock_size_t size, fptr_t func) {
    261254                        (this.data){data};
    262255                        (this.size){size};
Note: See TracChangeset for help on using the changeset viewer.