Changeset 8512a2f


Ignore:
Timestamp:
Mar 14, 2023, 3:51:03 PM (16 months ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
1950837
Parents:
3830c84
Message:

added libcfa support for virtual dtors and added it to actor impl

Location:
libcfa/src
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    r3830c84 r8512a2f  
    4848        math.hfa \
    4949        time_t.hfa \
     50    virtual_dtor.hfa \
    5051        bits/algorithm.hfa \
    5152        bits/align.hfa \
     
    6869        vec/vec2.hfa \
    6970        vec/vec3.hfa \
    70         vec/vec4.hfa
     71        vec/vec4.hfa 
    7172
    7273inst_headers_src = \
  • libcfa/src/concurrency/actor.hfa

    r3830c84 r8512a2f  
    55#include <kernel.hfa>
    66#include <iofwd.hfa>
     7#include <virtual_dtor.hfa>
    78
    89#ifdef __CFA_DEBUG__
     
    357358    if ( seperate_clus ) delete( cluster );
    358359
    359     #ifdef STATS
     360    #ifdef STATS // print formatted stats
    360361    printf("    Actor System Stats:\n");
    361362    printf("\tActors Created:\t\t\t\t%lu\n\tMessages Sent:\t\t\t\t%lu\n", __num_actors_stats, __all_processed);
     
    388389static executor * __actor_executor_ = 0p;
    389390static bool __actor_executor_passed = false;            // was an executor passed to start_actor_system
    390 static size_t __num_actors_ = 0;                                // number of actor objects in system
     391static size_t __num_actors_ = 0;                                        // number of actor objects in system
    391392static struct thread$ * __actor_executor_thd = 0p;              // used to wake executor after actors finish
    392393struct actor {
    393     size_t ticket;                              // executor-queue handle
     394    size_t ticket;                                          // executor-queue handle
    394395    Allocation allocation_;                                         // allocation action
     396    inline virtual_dtor;
    395397};
    396398
     
    406408    #endif
    407409}
    408 static inline void ^?{}( actor & this ) {}
    409410
    410411static inline void check_actor( actor & this ) {
     
    430431struct message {
    431432    Allocation allocation_;                     // allocation action
     433    inline virtual_dtor;
    432434};
    433435
    434 static inline void ?{}( message & this ) { this.allocation_ = Nodelete; }
     436static inline void ?{}( message & this ) {
     437    this.allocation_ = Nodelete;
     438}
    435439static inline void ?{}( message & this, Allocation allocation ) {
    436440    memcpy( &this.allocation_, &allocation, sizeof(allocation) ); // optimization to elide ctor
    437441    verifyf( this.allocation_ != Finished, "The Finished Allocation status is not supported for message types.\n");
    438442}
    439 static inline void ^?{}( message & this ) {
    440     CFA_DEBUG( if ( this.allocation_ == Nodelete ) printf("A message at location %p was allocated but never sent.\n", &this); )
     443static inline void ^?{}( message & this ) with(this) {
     444    CFA_DEBUG( if ( allocation_ == Nodelete ) printf("A message at location %p was allocated but never sent.\n", &this); )
    441445}
    442446
    443447static inline void check_message( message & this ) {
    444     #ifdef __CFA_DEBUG__
    445     Allocation temp = this.allocation_;
    446     this.allocation_ = Finished;
    447     switch ( temp )
    448     #else
    449     switch ( this.allocation_ )
    450     #endif
    451     {                                           // analyze message status
    452         case Nodelete: break;
     448    switch ( this.allocation_ ) {                                               // analyze message status
     449        case Nodelete: CFA_DEBUG(this.allocation_ = Finished); break;
    453450        case Delete: delete( &this ); break;
    454451        case Destroy: ^?{}(this); break;
     
    456453    } // switch
    457454}
    458 static inline void set_allocation( message & this, Allocation state ) { this.allocation_ = state; }
     455static inline void set_allocation( message & this, Allocation state ) {
     456    this.allocation_ = state;
     457}
    459458
    460459static inline void deliver_request( request & this ) {
     
    688687Allocation receive( actor & this, __DestroyMsg & msg ) { return Destroy; }
    689688Allocation receive( actor & this, __FinishedMsg & msg ) { return Finished; }
     689
Note: See TracChangeset for help on using the changeset viewer.