Changes in / [bae0d35:53692b3]


Ignore:
Location:
libcfa/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/defs.hfa

    rbae0d35 r53692b3  
    3131#ifdef __cforall
    3232#define __cfa_anonymous_object(x) inline struct x
    33 #define __cfa_dlink(x) inline dlink(x)
    3433#else
    3534#define __cfa_anonymous_object(x) struct x __cfa_anonymous_object
    36 #define __cfa_dlink(x) struct { struct x * next; struct x * back; } __dlink_substitute
    3735#endif
    3836
  • libcfa/src/bits/weakso_locks.hfa

    rbae0d35 r53692b3  
    2121#include "bits/sequence.hfa"
    2222#include "bits/containers.hfa"
    23 #include "containers/list.hfa"
    2423
    2524struct $thread;
     
    3231
    3332        // List of blocked threads
    34         dlist( $thread ) blocked_threads;
     33        Sequence( $thread ) blocked_threads;
    3534
    3635        // Count of current blocked threads
  • libcfa/src/concurrency/invoke.h

    rbae0d35 r53692b3  
    2020
    2121#ifdef __cforall
    22 #include "containers/list.hfa"
    2322extern "C" {
    2423#endif
     
    199198                } seqable;
    200199
    201                 // used to put threads on dlist data structure
    202                 __cfa_dlink($thread);
    203 
    204200                struct {
    205201                        struct $thread * next;
     
    213209                #endif
    214210        };
    215         #ifdef __cforall
    216                 P9_EMBEDDED( $thread, dlink($thread) )
    217         #endif
    218211        // Wrapper for gdb
    219212        struct cfathread_thread_t { struct $thread debug; };
     
    245238
    246239                static inline $thread *& Next( $thread * this ) __attribute__((const)) {
    247                                 return this->seqable.next;
     240                        return this->seqable.next;
    248241                }
    249242
  • libcfa/src/concurrency/locks.cfa

    rbae0d35 r53692b3  
    2727forall(L & | is_blocking_lock(L)) {
    2828        struct info_thread {
    29                 // used to put info_thread on a dl queue
    30                 inline dlink(info_thread(L));
     29                // used to put info_thread on a dl queue (aka sequence)
     30                inline Seqable;
    3131
    3232                // waiting thread
     
    4242                bool signalled;
    4343        };
    44         P9_EMBEDDED( info_thread(L), dlink(info_thread(L)) )
    4544
    4645        void ?{}( info_thread(L) & this, $thread * t, uintptr_t info, L * l ) {
     46                ((Seqable &) this){};
    4747                this.t = t;
    4848                this.info = info;
     
    5151
    5252        void ^?{}( info_thread(L) & this ) {}
     53
     54        info_thread(L) *& Back( info_thread(L) * this ) {
     55                return (info_thread(L) *)Back( (Seqable *)this );
     56        }
     57
     58        info_thread(L) *& Next( info_thread(L) * this ) {
     59                return (info_thread(L) *)Next( (Colable *)this );
     60        }
    5361}
    5462
     
    7785        // lock is held by some other thread
    7886        if ( owner != 0p && owner != thrd ) {
    79                 insert_last( blocked_threads, *thrd );
     87                addTail( blocked_threads, *thrd );
    8088                wait_count++;
    8189                unlock( lock );
     
    116124
    117125void pop_and_set_new_owner( blocking_lock & this ) with( this ) {
    118         $thread * t = &try_pop_front( blocked_threads );
     126        $thread * t = &dropHead( blocked_threads );
    119127        owner = t;
    120128        recursion_count = ( t ? 1 : 0 );
     
    145153        // lock held
    146154        if ( owner != 0p ) {
    147                 insert_last( blocked_threads, *t );
     155                addTail( blocked_threads, *t );
    148156                wait_count++;
    149157                unlock( lock );
     
    198206                //      may still be called after a thread has been removed from the queue but
    199207                //      before the alarm is unregistered
    200                 if ( (*info_thd)`isListed ) {   // is thread on queue
     208                if ( listed(info_thd) ) {       // is thread on queue
    201209                        info_thd->signalled = false;
    202210                        // remove this thread O(1)
    203                         remove( *info_thd );
     211                        remove( cond->blocked_threads, *info_thd );
    204212                        cond->count--;
    205213                        if( info_thd->lock ) {
     
    246254        bool notify_one( condition_variable(L) & this ) with( this ) {
    247255                lock( lock __cfaabi_dbg_ctx2 );
    248                 bool ret = ! blocked_threads`isEmpty;
    249                 process_popped(this, try_pop_front( blocked_threads ));
     256                bool ret = !empty(blocked_threads);
     257                process_popped(this, dropHead( blocked_threads ));
    250258                unlock( lock );
    251259                return ret;
     
    254262        bool notify_all( condition_variable(L) & this ) with(this) {
    255263                lock( lock __cfaabi_dbg_ctx2 );
    256                 bool ret = ! blocked_threads`isEmpty;
    257                 while( ! blocked_threads`isEmpty ) {
    258                         process_popped(this, try_pop_front( blocked_threads ));
     264                bool ret = !empty(blocked_threads);
     265                while( !empty(blocked_threads) ) {
     266                        process_popped(this, dropHead( blocked_threads ));
    259267                }
    260268                unlock( lock );
     
    263271
    264272        uintptr_t front( condition_variable(L) & this ) with(this) {
    265                 return blocked_threads`isEmpty ? NULL : blocked_threads`first.info;
     273                return empty(blocked_threads) ? NULL : head(blocked_threads).info;
    266274        }
    267275
    268276        bool empty( condition_variable(L) & this ) with(this) {
    269277                lock( lock __cfaabi_dbg_ctx2 );
    270                 bool ret = blocked_threads`isEmpty;
     278                bool ret = empty(blocked_threads);
    271279                unlock( lock );
    272280                return ret;
     
    277285        size_t queue_and_get_recursion( condition_variable(L) & this, info_thread(L) * i ) with(this) {
    278286                // add info_thread to waiting queue
    279                 insert_last( blocked_threads, *i );
     287                addTail( blocked_threads, *i );
    280288                count++;
    281289                size_t recursion_count = 0;
  • libcfa/src/concurrency/locks.hfa

    rbae0d35 r53692b3  
    2121#include "bits/weakso_locks.hfa"
    2222#include "containers/queueLockFree.hfa"
    23 #include "containers/list.hfa"
    2423
    2524#include "thread.hfa"
     
    4140
    4241static inline bool P(Semaphore0nary & this, $thread * thrd) {
    43         /* paranoid */ verify(!thrd`next);
    44         /* paranoid */ verify(!(&(*thrd)`next));
     42        /* paranoid */ verify(!(thrd->seqable.next));
     43        /* paranoid */ verify(!(thrd`next));
    4544
    4645        push(this.queue, thrd);
     
    251250
    252251//-----------------------------------------------------------------------------
    253 // // info_thread
    254 // // the info thread is a wrapper around a thread used
    255 // // to store extra data for use in the condition variable
     252// info_thread
     253// the info thread is a wrapper around a thread used
     254// to store extra data for use in the condition variable
    256255forall(L & | is_blocking_lock(L)) {
    257256        struct info_thread;
    258257
    259         // // for use by sequence
    260         // info_thread(L) *& Back( info_thread(L) * this );
    261         // info_thread(L) *& Next( info_thread(L) * this );
     258        // for use by sequence
     259        info_thread(L) *& Back( info_thread(L) * this );
     260        info_thread(L) *& Next( info_thread(L) * this );
    262261}
    263262
     
    270269
    271270                // List of blocked threads
    272                 dlist( info_thread(L) ) blocked_threads;
     271                Sequence( info_thread(L) ) blocked_threads;
    273272
    274273                // Count of current blocked threads
    275274                int count;
    276275        };
    277        
    278276
    279277        void  ?{}( condition_variable(L) & this );
Note: See TracChangeset for help on using the changeset viewer.