Changes in / [b6ec245:6e0f4bd]


Ignore:
Location:
src/libcfa/concurrency
Files:
4 edited

Legend:

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

    rb6ec245 r6e0f4bd  
    134134                // instrusive link field for threads
    135135                struct thread_desc * next;
     136
     137                __cfaabi_dbg_debug_do(
     138                        // instrusive link field for debugging
     139                        struct thread_desc * dbg_next;
     140                        struct thread_desc * dbg_prev;
     141                )
    136142     };
    137143
  • src/libcfa/concurrency/kernel.c

    rb6ec245 r6e0f4bd  
    611611}
    612612
     613//-----------------------------------------------------------------------------
     614// Debug
     615__cfaabi_dbg_debug_do(
     616        struct {
     617                thread_desc * tail;
     618        } __cfaabi_dbg_thread_list = { NULL };
     619
     620        void __cfaabi_dbg_thread_register( thread_desc * thrd ) {
     621                if( !__cfaabi_dbg_thread_list.tail ) {
     622                        __cfaabi_dbg_thread_list.tail = thrd;
     623                        return;
     624                }
     625                __cfaabi_dbg_thread_list.tail->dbg_next = thrd;
     626                thrd->dbg_prev = __cfaabi_dbg_thread_list.tail;
     627                __cfaabi_dbg_thread_list.tail = thrd;
     628        }
     629
     630        void __cfaabi_dbg_thread_unregister( thread_desc * thrd ) {
     631                thread_desc * prev = thrd->dbg_prev;
     632                thread_desc * next = thrd->dbg_next;
     633
     634                if( next ) { next->dbg_prev = prev; }
     635                else       {
     636                        assert( __cfaabi_dbg_thread_list.tail == thrd );
     637                        __cfaabi_dbg_thread_list.tail = prev;
     638                }
     639
     640                if( prev ) { prev->dbg_next = next; }
     641
     642                thrd->dbg_prev = NULL;
     643                thrd->dbg_next = NULL;
     644        }
     645)
    613646// Local Variables: //
    614647// mode: c //
  • src/libcfa/concurrency/kernel_private.h

    rb6ec245 r6e0f4bd  
    8585extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
    8686
     87__cfaabi_dbg_debug_do(
     88        extern void __cfaabi_dbg_thread_register  ( thread_desc * thrd );
     89        extern void __cfaabi_dbg_thread_unregister( thread_desc * thrd );
     90)
     91
    8792//-----------------------------------------------------------------------------
    8893// Utils
  • src/libcfa/concurrency/thread.c

    rb6ec245 r6e0f4bd  
    3333void ?{}(thread_desc& this) {
    3434        (this.self_cor){};
    35         this.self_cor.name = "Anonymous Coroutine";
     35        this.self_cor.name = "Anonymous Thread";
    3636        this.self_mon.owner = &this;
    3737        this.self_mon.recursion = 1;
    3838        this.self_mon_p = &this.self_mon;
    3939        this.next = NULL;
     40        __cfaabi_dbg_debug_do(
     41                this.dbg_next = NULL;
     42                this.dbg_prev = NULL;
     43                __cfaabi_dbg_thread_register(&this);
     44        )
    4045
    4146        (this.monitors){ &this.self_mon_p, 1, (fptr_t)0 };
     
    4348
    4449void ^?{}(thread_desc& this) {
     50        __cfaabi_dbg_debug_do(
     51                __cfaabi_dbg_thread_unregister(&this);
     52        )
    4553        ^(this.self_cor){};
    4654}
Note: See TracChangeset for help on using the changeset viewer.