Changeset e39cfb9


Ignore:
Timestamp:
Jun 19, 2023, 1:55:23 PM (11 months ago)
Author:
caparsons <caparson@…>
Branches:
master
Children:
0388a99
Parents:
ca0c311
Message:

various cleanups and improvements (shutdown flags, automatic processor count)

File:
1 edited

Legend:

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

    rca0c311 re39cfb9  
    5353    message * msg;
    5454    __receive_fn fn;
    55     // bool stop; // commented from change to termination flag from sentinels C_TODO: remove after confirming no performance degradation
    5655};
    5756
     
    5958    int m;
    6059};
    61 static inline void ?{}( request & this ) {
    62     // this.stop = true; // default ctor makes a sentinel
    63 }
     60static inline void ?{}( request & this ) {}
    6461static inline void ?{}( request & this, actor * base_receiver, actor * receiver, message * base_msg, message * msg, __receive_fn fn ) {
    6562    this.base_receiver = base_receiver;
     
    6865    this.msg = msg;
    6966    this.fn = fn;
    70     // this.stop = false;
    7167}
    7268static inline void ?{}( request & this, request & copy ) {
     
    7470    this.msg = copy.msg;
    7571    this.fn = copy.fn;
    76     // this.stop = copy.stop;
    7772}
    7873
     
    9792}
    9893
    99 static inline void insert( copy_queue & this, request & elem ) with(this) { // C_TODO: remove redundant send/insert once decision is made on emplace/copy
     94static inline void insert( copy_queue & this, request & elem ) with(this) {
    10095    if ( count >= buffer_size ) { // increase arr size
    10196        last_size = buffer_size;
     
    338333
    339334static inline void ^?{}( executor & this ) with(this) {
    340     // #ifdef __STEAL // commented from change to termination flag from sentinels C_TODO: remove after confirming no performance degradation
    341     // request sentinels[nrqueues];
    342     // for ( unsigned int i = 0; i < nrqueues; i++ ) {
    343     //     insert( request_queues[i], sentinels[i] );           // force eventually termination
    344     // } // for
    345     // #else
    346     // request sentinels[nworkers];
    347     // unsigned int reqPerWorker = nrqueues / nworkers, extras = nrqueues % nworkers;
    348     // for ( unsigned int i = 0, step = 0, range; i < nworkers; i += 1, step += range ) {
    349     //     range = reqPerWorker + ( i < extras ? 1 : 0 );
    350     //     insert( request_queues[step], sentinels[i] );                // force eventually termination
    351     // } // for
    352     // #endif
    353335    is_shutdown = true;
    354336
     
    614596        #ifdef __STEAL
    615597        if ( is_empty( *current_queue ) ) {
    616             if ( unlikely( no_steal ) ) { CHECK_TERMINATION; continue; } // C_TODO: if this impacts static/dynamic perf refactor check
     598            if ( unlikely( no_steal ) ) { CHECK_TERMINATION; continue; }
    617599            empty_count++;
    618600            if ( empty_count < steal_threshold ) continue;
     
    637619            &req = &remove( *current_queue );
    638620            if ( !&req ) continue;
    639             // if ( req.stop ) break Exit;
    640621            deliver_request( req );
    641622        }
     
    679660}
    680661
    681 // TODO: potentially revisit getting number of processors
    682 //  ( currently the value stored in active_cluster()->procs.total is often stale
    683 //  and doesn't reflect how many procs are allocated )
    684 // static inline void start_actor_system() { start_actor_system( active_cluster()->procs.total ); }
    685 static inline void start_actor_system() { start_actor_system( 1 ); }
     662static inline void start_actor_system() { start_actor_system( get_proc_count( *active_cluster() ) ); }
    686663
    687664static inline void start_actor_system( executor & this ) {
     
    693670
    694671static inline void stop_actor_system() {
    695     park( ); // will receive signal when actor system is finished
     672    park( ); // will be unparked when actor system is finished
    696673
    697674    if ( !__actor_executor_passed ) delete( __actor_executor_ );
Note: See TracChangeset for help on using the changeset viewer.