Changeset ee897e4b for src/libcfa


Ignore:
Timestamp:
Feb 13, 2017, 5:13:11 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:
eafb094
Parents:
db6f06a
Message:

Made some clean-up and removed redundant coroutine state

Location:
src/libcfa/concurrency
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/coroutines

    rdb6f06a ree897e4b  
    7777                "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.",
    7878                src->name, src );
    79         assertf( src->last->notHalted,
     79        assertf( src->last->state != Halted,
    8080                "Attempt by coroutine \"%.256s\" (%p) to suspend back to terminated coroutine \"%.256s\" (%p).\n"
    8181                "Possible cause is terminated coroutine's main routine has already returned.",
     
    9898      // not resuming self ?
    9999        if ( src != dst ) {
    100                 assertf( dst->notHalted ,
     100                assertf( dst->state != Halted ,
    101101                        "Attempt by coroutine %.256s (%p) to resume terminated coroutine %.256s (%p).\n"
    102102                        "Possible cause is terminated coroutine's main routine has already returned.",
     
    116116      // not resuming self ?
    117117        if ( src != dst ) {
    118                 assertf( dst->notHalted ,
     118                assertf( dst->state != Halted ,
    119119                        "Attempt by coroutine %.256s (%p) to resume terminated coroutine %.256s (%p).\n"
    120120                        "Possible cause is terminated coroutine's main routine has already returned.",
  • src/libcfa/concurrency/coroutines.c

    rdb6f06a ree897e4b  
    6868        this->errno_ = 0;
    6969        this->state = Start;
    70         this->notHalted = true;
    7170        this->starter = NULL;
    7271        this->last = NULL;
  • src/libcfa/concurrency/invoke.c

    rdb6f06a ree897e4b  
    4848      main( this );
    4949
    50       cor->state = Halt;
    51       cor->notHalted = false;
     50      cor->state = Halted;
    5251
    5352      //Final suspend, should never return
  • src/libcfa/concurrency/invoke.h

    rdb6f06a ree897e4b  
    3939      };
    4040
    41       // struct simple_lock {
    42       //        struct simple_thread_list blocked;
    43       // };
    44 
    4541      struct signal_once {
    4642            volatile bool condition;
     
    5450            void append( struct simple_thread_list *, struct thread * );
    5551            struct thread * pop_head( struct simple_thread_list * );
    56 
    57             // void ?{}(simple_lock * this);
    58             // void ^?{}(simple_lock * this);
    5952
    6053            void ?{}(spinlock * this);
     
    7669      };
    7770
    78       enum coroutine_state { Start, Inactive, Active, Halt, Primed };
     71      enum coroutine_state { Halted, Start, Inactive, Active, Primed };
    7972
    8073      struct coroutine {
     
    8376            int errno_;                         // copy of global UNIX variable errno
    8477            enum coroutine_state state; // current execution status for coroutine
    85             bool notHalted;                   // indicate if execuation state is not halted
    8678            struct coroutine *starter;  // first coroutine to resume this one
    8779            struct coroutine *last;             // last coroutine to resume this one
     
    8981
    9082      struct thread {
    91             struct coroutine c;
    92             signal_once terminated;             // indicate if execuation state is not halted
    93             struct thread * next;
     83            struct coroutine c;           // coroutine body used to store context
     84            struct signal_once terminated;// indicate if execuation state is not halted
     85            struct thread * next;         // instrusive link field for threads
    9486      };
    9587
  • src/libcfa/concurrency/kernel.c

    rdb6f06a ree897e4b  
    119119        this->name = "Main Thread";
    120120        this->errno_ = 0;
    121         this->state = Inactive;
    122         this->notHalted = true;
     121        this->state = Start;
    123122}
    124123
     
    287286        proc_cor_storage.c.state = Active;
    288287      main( &proc_cor_storage );
    289       proc_cor_storage.c.state = Halt;
    290       proc_cor_storage.c.notHalted = false;
     288      proc_cor_storage.c.state = Halted;
    291289
    292290        // Main routine of the core returned, the core is now fully terminated
  • src/libcfa/concurrency/threads.c

    rdb6f06a ree897e4b  
    120120extern "C" {
    121121        void __thread_signal_termination( thread * this ) {
    122                 this->c.state = Halt;
     122                this->c.state = Halted;
    123123                LIB_DEBUG_PRINTF("Thread end : %p\n", this);
    124124                signal( &this->terminated );   
Note: See TracChangeset for help on using the changeset viewer.