Ignore:
Timestamp:
2019-07-02T14:19:24Z (5 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4dfb259
Parents:
72786f38
Message:

cpp: make sure exceptions are stored when we set value at thread exit too

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/__bits/thread/promise.hpp

    r72786f38 r5ab9df4  
    225225                }
    226226
    227                 this->state_->set_value(val, false);
    228                 aux::set_state_value_at_thread_exit(state_);
     227                try
     228                {
     229                    state_->set_value(invoke(func_, args...), false);
     230                    aux::set_state_value_at_thread_exit(this->state_);
     231                }
     232                catch(const exception& __exception)
     233                {
     234                    state_->set_exception(make_exception_ptr(__exception), false);
     235                    aux::set_state_exception_at_thread_exit(this->state_);
     236                }
    229237            }
    230238
     
    240248                }
    241249
    242                 this->state_->set_value(forward<R>(val), false);
    243                 aux::set_state_value_at_thread_exit(state_);
     250                try
     251                {
     252                    state_->set_value(invoke(func_, args...), false);
     253                    aux::set_state_value_at_thread_exit(this->state_);
     254                }
     255                catch(const exception& __exception)
     256                {
     257                    state_->set_exception(make_exception_ptr(__exception), false);
     258                    aux::set_state_exception_at_thread_exit(this->state_);
     259                }
    244260            }
    245261    };
     
    311327                }
    312328
    313                 this->state_->set_value(&val, false);
    314                 aux::set_state_value_at_thread_exit(state_);
     329                try
     330                {
     331                    state_->set_value(invoke(func_, args...), false);
     332                    aux::set_state_value_at_thread_exit(this->state_);
     333                }
     334                catch(const exception& __exception)
     335                {
     336                    state_->set_exception(make_exception_ptr(__exception), false);
     337                    aux::set_state_exception_at_thread_exit(this->state_);
     338                }
    315339            }
    316340    };
Note: See TracChangeset for help on using the changeset viewer.