Changeset 063e0626 in mainline


Ignore:
Timestamp:
2018-07-05T21:41:20Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a75f3e49
Parents:
4fe4ea6
git-author:
Dzejrou <dzejrou@…> (2018-03-02 19:55:30)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:20)
Message:

cpp: fixed thread lifetime management as per standard

Location:
uspace/lib/cpp
Files:
2 edited

Legend:

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

    r4fe4ea6 r063e0626  
    3434#include <ostream>
    3535
     36extern "C" {
     37    #include <fibril.h>
     38    #include <fibril_synch.h>
     39}
     40
    3641namespace std
    3742{
    38     extern "C" {
    39         #include <fibril.h>
    40         #include <fibril_synch.h>
    41     }
    42 
    4343    namespace aux
    4444    {
     
    200200            (*callable)();
    201201
    202             if (callable->detached()) // No thread owns the wrapper.
     202            if (callable->detached())
    203203                delete callable;
    204204
  • uspace/lib/cpp/src/thread.cpp

    r4fe4ea6 r063e0626  
    3939    thread::~thread()
    4040    {
    41         // TODO: Change this to std::terminate when implemented.
    4241        if (joinable())
    4342        {
    44             if (joinable_wrapper_ && !joinable_wrapper_->detached())
    45             {
    46                 joinable_wrapper_->join();
    47                 delete joinable_wrapper_;
    48             }
     43            // TODO: call std::terminate
     44        }
    4945
    50             // TODO: this crashes :(
    51             /* fibril_teardown((fibril_t*)id_, false); */
    52             /* std::abort(); */
    53         }
     46        if (joinable_wrapper_ && !joinable_wrapper_->detached())
     47            delete joinable_wrapper_;
    5448    }
    5549
     
    6256    thread& thread::operator=(thread&& other) noexcept
    6357    {
     58        if (joinable())
     59        {
     60            // TODO: call std::terminate
     61        }
     62
    6463        id_ = other.id_;
    6564        other.id_ = fid_t{};
     
    8079    void thread::join()
    8180    {
    82         if (joinable_wrapper_)
     81        if (joinable() && joinable_wrapper_)
    8382            joinable_wrapper_->join();
    8483    }
Note: See TracChangeset for help on using the changeset viewer.