Changeset 48ec19a for libcfa/src


Ignore:
Timestamp:
Jun 26, 2023, 10:51:47 AM (2 years ago)
Author:
caparson <caparson@…>
Branches:
master
Children:
917e1fd
Parents:
adc73a5 (diff), 1fbf481 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/actor.hfa

    radc73a5 r48ec19a  
    390390struct actor {
    391391    size_t ticket;                                          // executor-queue handle
    392     allocation allocation_;                                         // allocation action
     392    allocation alloc;                                       // allocation action
    393393    inline virtual_dtor;
    394394};
     
    398398    // member must be called to end it
    399399    DEBUG_ABORT( __actor_executor_ == 0p, "Creating actor before calling start_actor_system() can cause undefined behaviour.\n" );
    400     allocation_ = Nodelete;
     400    alloc = Nodelete;
    401401    ticket = __get_next_ticket( *__actor_executor_ );
    402402    __atomic_fetch_add( &__num_actors_, 1, __ATOMIC_RELAXED );
     
    407407
    408408static inline void check_actor( actor & this ) {
    409     if ( this.allocation_ != Nodelete ) {
    410         switch( this.allocation_ ) {
     409    if ( this.alloc != Nodelete ) {
     410        switch( this.alloc ) {
    411411            case Delete: delete( &this ); break;
    412412            case Destroy:
     
    427427
    428428struct message {
    429     allocation allocation_;                     // allocation action
     429    allocation alloc;                   // allocation action
    430430    inline virtual_dtor;
    431431};
    432432
    433433static inline void ?{}( message & this ) {
    434     this.allocation_ = Nodelete;
     434    this.alloc = Nodelete;
    435435}
    436436static inline void ?{}( message & this, allocation alloc ) {
    437     memcpy( &this.allocation_, &alloc, sizeof(allocation) ); // optimization to elide ctor
    438     DEBUG_ABORT( this.allocation_ == Finished, "The Finished allocation status is not supported for message types.\n" );
     437    memcpy( &this.alloc, &alloc, sizeof(allocation) ); // optimization to elide ctor
     438    CFA_DEBUG( if( this.alloc == Finished ) this.alloc = Nodelete; )
    439439}
    440440static inline void ^?{}( message & this ) with(this) {
    441     CFA_DEBUG( if ( allocation_ == Nodelete ) printf("A message at location %p was allocated but never sent.\n", &this); )
     441    CFA_DEBUG(
     442                if ( alloc == Nodelete ) {
     443                        printf( "CFA warning (UNIX pid:%ld) : program terminating with message %p allocated but never sent.\n",
     444                                        (long int)getpid(), &this );
     445                }
     446        )
    442447}
    443448
    444449static inline void check_message( message & this ) {
    445     switch ( this.allocation_ ) {                                               // analyze message status
    446         case Nodelete: CFA_DEBUG( this.allocation_ = Finished ); break;
     450    switch ( this.alloc ) {                                             // analyze message status
     451        case Nodelete: CFA_DEBUG( this.alloc = Finished ); break;
    447452        case Delete: delete( &this ); break;
    448453        case Destroy: ^?{}( this ); break;
     
    451456}
    452457static inline void set_allocation( message & this, allocation state ) {
    453     this.allocation_ = state;
     458    CFA_DEBUG( if ( state == Nodelete ) state = Finished; )
     459    this.alloc = state;
    454460}
    455461
     
    459465    message * base_msg;
    460466    allocation temp = this.fn( *this.receiver, *this.msg, &base_actor, &base_msg );
    461     base_actor->allocation_ = temp;
     467    memcpy( &base_actor->alloc, &temp, sizeof(allocation) ); // optimization to elide ctor
    462468    check_message( *base_msg );
    463469    check_actor( *base_actor );
     
    624630        empty_count = 0; // we found work so reset empty counter
    625631        #endif
     632
     633        CHECK_TERMINATION;
    626634       
    627635        // potentially reclaim some of the current queue's vector space if it is unused
     
    669677
    670678static inline void stop_actor_system() {
    671     park( ); // will be unparked when actor system is finished
     679    park( ); // unparked when actor system is finished
    672680
    673681    if ( !__actor_executor_passed ) delete( __actor_executor_ );
     
    680688// Default messages to send to any actor to change status
    681689// assigned at creation to __base_msg_finished to avoid unused message warning
    682 message __base_msg_finished @= { .allocation_ : Finished };
    683 struct __delete_msg_t { inline message; } delete_msg = __base_msg_finished;
    684 struct __destroy_msg_t { inline message; } destroy_msg = __base_msg_finished;
    685 struct __finished_msg_t { inline message; } finished_msg = __base_msg_finished;
    686 
    687 allocation receive( actor & this, __delete_msg_t & msg ) { return Delete; }
    688 allocation receive( actor & this, __destroy_msg_t & msg ) { return Destroy; }
    689 allocation receive( actor & this, __finished_msg_t & msg ) { return Finished; }
    690 
     690message __base_msg_finished @= { .alloc : Finished };
     691struct delete_message_t { inline message; } delete_msg = __base_msg_finished;
     692struct destroy_msg_t { inline message; } destroy_msg = __base_msg_finished;
     693struct finished_msg_t { inline message; } finished_msg = __base_msg_finished;
     694
     695allocation receive( actor & this, delete_message_t & msg ) { return Delete; }
     696allocation receive( actor & this, destroy_msg_t & msg ) { return Destroy; }
     697allocation receive( actor & this, finished_msg_t & msg ) { return Finished; }
     698
  • libcfa/src/parseargs.cfa

    radc73a5 r48ec19a  
    230230}
    231231
    232 void print_args_usage(cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn)) {
     232void print_args_usage(cfa_option options[], const size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn)) {
    233233        const array( cfa_option, opt_count ) & arr = (const array( cfa_option, opt_count ) &) *options;
    234234        usage(cfa_args_argv[0], arr, usage, error ? stderr : stdout);
    235235}
    236236
    237 void print_args_usage(int , char * argv[], cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn)) {
     237void print_args_usage(int , char * argv[], cfa_option options[], const size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn)) {
    238238        const array( cfa_option, opt_count ) & arr = (const array( cfa_option, opt_count ) &) *options;
    239239        usage(argv[0], arr, usage, error ? stderr : stdout);
Note: See TracChangeset for help on using the changeset viewer.