Changeset 72786f38 in mainline


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

cpp: moved all the at_exit logic to two functions which are to be implemented later to avoid TODO duplication throughout the code

Location:
uspace/lib/cpp/include/__bits/thread
Files:
3 edited

Legend:

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

    rd3ba97d r72786f38  
    179179            void make_ready_at_thread_exit(Args...)
    180180            {
    181                 // TODO: implement
     181                if (!state_)
     182                    throw future_error{make_error_code(future_errc::no_state)};
     183                if (state_->is_set())
     184                {
     185                    throw future_error{
     186                        make_error_code(future_errc::promise_already_satisfied)
     187                    };
     188                }
     189
     190                try
     191                {
     192                    state_->set_value(invoke(func_, args...), false);
     193                }
     194                catch(const exception& __exception)
     195                {
     196                    state_->set_exception(make_exception_ptr(__exception), false);
     197                }
     198
     199                aux::set_state_value_at_thread_exit(state_);
    182200            }
    183201
  • uspace/lib/cpp/include/__bits/thread/promise.hpp

    rd3ba97d r72786f38  
    106106
    107107                    state_->set_exception_ptr(ptr, false);
    108                     // TODO: Mark it as 'has_exception' when thread terminates.
     108                    aux::set_state_exception_at_thread_exit(state_);
    109109                }
    110110
     
    226226
    227227                this->state_->set_value(val, false);
    228                 // TODO: schedule it to be set as ready when thread exits
     228                aux::set_state_value_at_thread_exit(state_);
    229229            }
    230230
     
    241241
    242242                this->state_->set_value(forward<R>(val), false);
    243                 // TODO: schedule it to be set as ready when thread exits
     243                aux::set_state_value_at_thread_exit(state_);
    244244            }
    245245    };
     
    312312
    313313                this->state_->set_value(&val, false);
    314                 // TODO: schedule it to be set as ready when thread exits
     314                aux::set_state_value_at_thread_exit(state_);
    315315            }
    316316    };
  • uspace/lib/cpp/include/__bits/thread/shared_state.hpp

    rd3ba97d r72786f38  
    371371            }
    372372    };
     373
     374    /**
     375     * Note: The following two functions should:
     376     *   1) Increment refcount.
     377     *   2) Store ptr to a vector of shared_state_base ptrs
     378     *      (as those have ::mark_set member functions).
     379     *   3) If not done already, register a function
     380     *      executing all these in the thread_atexit function
     381     *      once that is implemented.
     382     */
     383
     384    template<class R>
     385    void set_state_value_at_thread_exit(shared_state<R>* state)
     386    {
     387        // TODO: implement
     388    }
     389
     390    template<class R>
     391    void set_state_exception_at_thread_exit(shared_state<R>* state)
     392    {
     393        // TODO: implement
     394    }
    373395}
    374396
Note: See TracChangeset for help on using the changeset viewer.