Opened 11 years ago

Closed 11 years ago

#6292 closed Bugs (invalid)

native_handle_type missing on timed_mutex/recursive_timed_mutex when they are not native but emulated

Reported by: viboes Owned by: viboes
Milestone: To Be Determined Component: thread
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

boost/pthread/mutex.hpp defines

        typedef pthread_mutex_t* native_handle_type;
        native_handle_type native_handle()
        {
            return &m;
        }

only when BOOST_PTHREAD_HAS_TIMEDLOCK is defined.

The following error occurs when trying to use them

clang-darwin.compile.c++ ../../../bin.v2/libs/thread/test/v2_timed_mutex_native_handle_pass.test/clang-darwin-2.9x/debug/threading-multi/sync/mutual_exclusion/timed_mutex/native_handle_pass.o
sync/mutual_exclusion/timed_mutex/native_handle_pass.cpp:29:23: error: no member named 'native_handle_type' in 'boost::timed_mutex'
  boost::timed_mutex::native_handle_type h = m.native_handle();
  ~~~~~~~~~~~~~~~~~~~~^

It seems to me that even some kind of handle must be returned by the native_handle function in this case.

Maybe the return type could be a pointer to struct containing the implementation fields

 struct native_handle_struct {
        pthread_mutex_t m;
        pthread_cond_t cond;
        bool is_locked;
 };
 typedef native_handle_struct* native_handle_type;

Change History (3)

comment:1 by viboes, 11 years ago

Summary: native_handle_type missing on timed_mutex when BOOST_PTHREAD_HAS_TIMEDLOCK is not definednative_handle_type missing on timed_mutex/recursive_timed_mutex when BOOST_PTHREAD_HAS_TIMEDLOCK is not defined

The same applies to recursive_timed_mutex.

comment:2 by viboes, 11 years ago

Summary: native_handle_type missing on timed_mutex/recursive_timed_mutex when BOOST_PTHREAD_HAS_TIMEDLOCK is not definednative_handle_type missing on timed_mutex/recursive_timed_mutex when they are not native but emulated

The same applies to Windows as timed mutex are emulated.

comment:3 by viboes, 11 years ago

Resolution: invalid
Status: newclosed

Well, after reading the standard it is implementation-defined, so Boost.Thread is conforming without providing them.

Note: See TracTickets for help on using tickets.