thread (thread::id): Move definition inside thread.
2009-02-06 Benjamin Kosnik <bkoz@redhat.com>
* include/std/thread (thread::id): Move definition inside thread.
Use native_handle_type. Remove this_thread::get_id friend.
Change __thread_data_ptr to __shared_base_ptr.
(thread:🆔:id(native_handle_type): Make public. Still explicit.
Use native_handle_type. Change _M_thread_id to _M_thread.
(thread::__thread_data_base): Rename to _Impl_base. Use id, change
_M_thread_handle to _M_id.
(thread::__thread_data): Rename to _Impl.
Fixup for renames.
(thread::_M_make_thread_data): Return derived type.
(thread::hardware_concurrency): Add definition for default case.
(thread::get_id): Now can define inline.
(thread): Change _M_thread_data to _M_data.
(this_thread::get_id): Now can define inline.
* src/thread.cc (__thread_proxy): Rename to
execute_native_thread_routine.
Fixup for other renames.
* testsuite/30_threads/thread/cons/assign_neg.cc: New.
* testsuite/30_threads/thread/cons/copy_neg.cc: New.
* testsuite/30_threads/thread/algorithm: Move to..
* testsuite/30_threads/thread/swap: ...this.
* testsuite/30_threads/thread/member/hardware_concurrency.cc: Add.
* testsuite/30_threads/thread/id/operators.cc: New.
From-SVN: r144007
This commit is contained in:
parent
5a7e237c63
commit
d7afcd2b9b
@ -1,3 +1,29 @@
|
|||||||
|
2009-02-06 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
* include/std/thread (thread::id): Move definition inside thread.
|
||||||
|
Use native_handle_type. Remove this_thread::get_id friend.
|
||||||
|
Change __thread_data_ptr to __shared_base_ptr.
|
||||||
|
(thread::id::id(native_handle_type): Make public. Still explicit.
|
||||||
|
Use native_handle_type. Change _M_thread_id to _M_thread.
|
||||||
|
(thread::__thread_data_base): Rename to _Impl_base. Use id, change
|
||||||
|
_M_thread_handle to _M_id.
|
||||||
|
(thread::__thread_data): Rename to _Impl.
|
||||||
|
Fixup for renames.
|
||||||
|
(thread::_M_make_thread_data): Return derived type.
|
||||||
|
(thread::hardware_concurrency): Add definition for default case.
|
||||||
|
(thread::get_id): Now can define inline.
|
||||||
|
(thread): Change _M_thread_data to _M_data.
|
||||||
|
(this_thread::get_id): Now can define inline.
|
||||||
|
* src/thread.cc (__thread_proxy): Rename to
|
||||||
|
execute_native_thread_routine.
|
||||||
|
Fixup for other renames.
|
||||||
|
* testsuite/30_threads/thread/cons/assign_neg.cc: New.
|
||||||
|
* testsuite/30_threads/thread/cons/copy_neg.cc: New.
|
||||||
|
* testsuite/30_threads/thread/algorithm: Move to..
|
||||||
|
* testsuite/30_threads/thread/swap: ...this.
|
||||||
|
* testsuite/30_threads/thread/member/hardware_concurrency.cc: Add.
|
||||||
|
* testsuite/30_threads/thread/id/operators.cc: New.
|
||||||
|
|
||||||
2009-02-05 Chris Fairles <cfairles@gcc.gnu.org>
|
2009-02-05 Chris Fairles <cfairles@gcc.gnu.org>
|
||||||
|
|
||||||
* include/std/tuple (_Head_base<>::_Head_base(_UHead&&)): Formatting.
|
* include/std/tuple (_Head_base<>::_Head_base(_UHead&&)): Formatting.
|
||||||
@ -7,13 +33,13 @@
|
|||||||
|
|
||||||
2009-02-05 Chris Fairles <cfairles@gcc.gnu.org>
|
2009-02-05 Chris Fairles <cfairles@gcc.gnu.org>
|
||||||
Benjamin Kosnik <bkoz@redhat.com>
|
Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
* include/std/thread (__thread_data_base): Nest class in std::thread.
|
* include/std/thread (__thread_data_base): Nest class in std::thread.
|
||||||
(__thread_data): Likewise.
|
(__thread_data): Likewise.
|
||||||
(__thread_data_ptr): Nest typedef in std::thread.
|
(__thread_data_ptr): Nest typedef in std::thread.
|
||||||
* src/thread.cc (__thread_proxy): Qualify the above names.
|
* src/thread.cc (__thread_proxy): Qualify the above names.
|
||||||
* config/abi/pre/gnu.ver: Remove unused exports.
|
* config/abi/pre/gnu.ver: Remove unused exports.
|
||||||
|
|
||||||
2009-02-04 Benjamin Kosnik <bkoz@redhat.com>
|
2009-02-04 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
* include/bits/unique_ptr.h: Remove private __this_type typedef.
|
* include/bits/unique_ptr.h: Remove private __this_type typedef.
|
||||||
|
@ -53,115 +53,149 @@
|
|||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
|
/// thread
|
||||||
class thread
|
class thread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class __thread_data_base;
|
typedef __gthread_t native_handle_type;
|
||||||
|
|
||||||
typedef shared_ptr<__thread_data_base> __thread_data_ptr;
|
|
||||||
|
|
||||||
class __thread_data_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
__thread_data_base() = default;
|
|
||||||
virtual ~__thread_data_base() = default;
|
|
||||||
|
|
||||||
virtual void _M_run() = 0;
|
|
||||||
|
|
||||||
__gthread_t _M_thread_handle;
|
|
||||||
__thread_data_ptr _M_this_ptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
// types
|
|
||||||
class id;
|
|
||||||
typedef __gthread_t native_handle_type;
|
|
||||||
|
|
||||||
// cons
|
/// thread::id
|
||||||
|
class id
|
||||||
|
{
|
||||||
|
native_handle_type _M_thread;
|
||||||
|
|
||||||
|
public:
|
||||||
|
id() : _M_thread() { }
|
||||||
|
|
||||||
|
explicit
|
||||||
|
id(native_handle_type __id) : _M_thread(__id) { }
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class thread;
|
||||||
|
|
||||||
|
friend bool
|
||||||
|
operator==(thread::id __x, thread::id __y)
|
||||||
|
{ return __gthread_equal(__x._M_thread, __y._M_thread); }
|
||||||
|
|
||||||
|
friend bool
|
||||||
|
operator<(thread::id __x, thread::id __y)
|
||||||
|
{ return __x._M_thread < __y._M_thread; }
|
||||||
|
|
||||||
|
template<class _CharT, class _Traits>
|
||||||
|
friend basic_ostream<_CharT, _Traits>&
|
||||||
|
operator<<(basic_ostream<_CharT, _Traits>&& __out, thread::id __id);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Impl_base;
|
||||||
|
typedef shared_ptr<_Impl_base> __shared_base_type;
|
||||||
|
|
||||||
|
struct _Impl_base
|
||||||
|
{
|
||||||
|
id _M_id;
|
||||||
|
__shared_base_type _M_this_ptr;
|
||||||
|
|
||||||
|
_Impl_base() = default;
|
||||||
|
|
||||||
|
virtual ~_Impl_base() = default;
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
_M_run() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename _Callable>
|
||||||
|
class _Impl : public _Impl_base
|
||||||
|
{
|
||||||
|
_Callable _M_func;
|
||||||
|
|
||||||
|
public:
|
||||||
|
_Impl(_Callable&& __f) : _M_func(std::forward<_Callable>(__f))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void
|
||||||
|
_M_run() { _M_func(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
// NB: Store the base type here.
|
||||||
|
__shared_base_type _M_data;
|
||||||
|
|
||||||
|
public:
|
||||||
thread() = default;
|
thread() = default;
|
||||||
|
thread(const thread&) = delete;
|
||||||
|
|
||||||
|
thread(thread&& __t)
|
||||||
|
{ swap(__t); }
|
||||||
|
|
||||||
template<typename _Callable>
|
template<typename _Callable>
|
||||||
explicit thread(_Callable __f)
|
explicit thread(_Callable __f)
|
||||||
: _M_thread_data(_M_make_thread_data(__f))
|
: _M_data(_M_make_shared_data(__f))
|
||||||
{ _M_start_thread(); }
|
{ _M_start_thread(); }
|
||||||
|
|
||||||
template<typename _Callable, typename... _Args>
|
template<typename _Callable, typename... _Args>
|
||||||
thread(_Callable&& __f, _Args&&... __args)
|
thread(_Callable&& __f, _Args&&... __args)
|
||||||
: _M_thread_data(_M_make_thread_data(std::bind(__f, __args...)))
|
: _M_data(_M_make_shared_data(std::bind(__f, __args...)))
|
||||||
{ _M_start_thread(); }
|
{ _M_start_thread(); }
|
||||||
|
|
||||||
~thread()
|
~thread()
|
||||||
{
|
{
|
||||||
if (joinable())
|
if (joinable())
|
||||||
detach();
|
detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
thread(const thread&) = delete;
|
|
||||||
thread(thread&& __t)
|
|
||||||
{ swap(__t); }
|
|
||||||
|
|
||||||
thread& operator=(const thread&) = delete;
|
thread& operator=(const thread&) = delete;
|
||||||
|
|
||||||
thread& operator=(thread&& __t)
|
thread& operator=(thread&& __t)
|
||||||
{
|
{
|
||||||
if (joinable())
|
if (joinable())
|
||||||
detach();
|
detach();
|
||||||
swap(__t);
|
swap(__t);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// members
|
void
|
||||||
void
|
|
||||||
swap(thread&& __t)
|
swap(thread&& __t)
|
||||||
{ std::swap(_M_thread_data, __t._M_thread_data); }
|
{ std::swap(_M_data, __t._M_data); }
|
||||||
|
|
||||||
bool
|
bool
|
||||||
joinable() const
|
joinable() const
|
||||||
{ return _M_thread_data; }
|
{ return _M_data; }
|
||||||
|
|
||||||
void
|
void
|
||||||
join();
|
join();
|
||||||
|
|
||||||
void
|
void
|
||||||
detach();
|
detach();
|
||||||
|
|
||||||
thread::id
|
thread::id
|
||||||
get_id() const;
|
get_id() const
|
||||||
|
{
|
||||||
|
if (_M_data)
|
||||||
|
return thread::id(_M_data->_M_id._M_thread);
|
||||||
|
else
|
||||||
|
return thread::id();
|
||||||
|
}
|
||||||
|
|
||||||
/** @pre thread is joinable
|
/** @pre thread is joinable
|
||||||
*/
|
*/
|
||||||
native_handle_type
|
native_handle_type
|
||||||
native_handle()
|
native_handle()
|
||||||
{ return _M_thread_data->_M_thread_handle; }
|
{ return _M_data->_M_id._M_thread; }
|
||||||
|
|
||||||
// static members
|
// Returns a value that hints at the number of hardware thread contexts.
|
||||||
static unsigned hardware_concurrency();
|
static unsigned int
|
||||||
|
hardware_concurrency()
|
||||||
|
{ return 0; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename _Callable>
|
template<typename _Callable>
|
||||||
class __thread_data : public __thread_data_base
|
shared_ptr<_Impl<_Callable>>
|
||||||
|
_M_make_shared_data(_Callable&& __f)
|
||||||
{
|
{
|
||||||
public:
|
// Create and allocate full data structure, not base.
|
||||||
__thread_data(_Callable&& __f)
|
return make_shared<_Impl<_Callable>>(std::forward<_Callable>(__f));
|
||||||
: _M_func(std::forward<_Callable>(__f))
|
|
||||||
{ }
|
|
||||||
|
|
||||||
void _M_run()
|
|
||||||
{ _M_func(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
_Callable _M_func;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _Callable>
|
|
||||||
__thread_data_ptr
|
|
||||||
_M_make_thread_data(_Callable&& __f)
|
|
||||||
{
|
|
||||||
return make_shared<__thread_data<_Callable>>(
|
|
||||||
std::forward<_Callable>(__f));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _M_start_thread();
|
|
||||||
|
|
||||||
__thread_data_ptr _M_thread_data;
|
void _M_start_thread();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
@ -171,15 +205,42 @@ namespace std
|
|||||||
inline void
|
inline void
|
||||||
swap(thread&& __x, thread& __y)
|
swap(thread&& __x, thread& __y)
|
||||||
{ __x.swap(__y); }
|
{ __x.swap(__y); }
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
swap(thread& __x, thread&& __y)
|
swap(thread& __x, thread&& __y)
|
||||||
{ __x.swap(__y); }
|
{ __x.swap(__y); }
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator!=(thread::id __x, thread::id __y)
|
||||||
|
{ return !(__x == __y); }
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator<=(thread::id __x, thread::id __y)
|
||||||
|
{ return !(__y < __x); }
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator>(thread::id __x, thread::id __y)
|
||||||
|
{ return __y < __x; }
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator>=(thread::id __x, thread::id __y)
|
||||||
|
{ return !(__x < __y); }
|
||||||
|
|
||||||
|
template<class _CharT, class _Traits>
|
||||||
|
inline basic_ostream<_CharT, _Traits>&
|
||||||
|
operator<<(basic_ostream<_CharT, _Traits>&& __out, thread::id __id)
|
||||||
|
{
|
||||||
|
if (__id == thread::id())
|
||||||
|
return __out << "thread::id of a non-executing thread";
|
||||||
|
else
|
||||||
|
return __out << __id._M_thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 30.2.2 Namespace this_thread.
|
||||||
namespace this_thread
|
namespace this_thread
|
||||||
{
|
{
|
||||||
thread::id
|
thread::id
|
||||||
get_id();
|
get_id() { return thread::id(__gthread_self()); }
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_SCHED_YIELD
|
#ifdef _GLIBCXX_USE_SCHED_YIELD
|
||||||
inline void
|
inline void
|
||||||
@ -203,7 +264,7 @@ namespace std
|
|||||||
chrono::nanoseconds __ns =
|
chrono::nanoseconds __ns =
|
||||||
chrono::duration_cast<chrono::nanoseconds>(__rtime - __s);
|
chrono::duration_cast<chrono::nanoseconds>(__rtime - __s);
|
||||||
|
|
||||||
__gthread_time_t __ts =
|
__gthread_time_t __ts =
|
||||||
{
|
{
|
||||||
static_cast<std::time_t>(__s.count()),
|
static_cast<std::time_t>(__s.count()),
|
||||||
static_cast<long>(__ns.count())
|
static_cast<long>(__ns.count())
|
||||||
@ -213,79 +274,6 @@ namespace std
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// thread::id
|
|
||||||
class thread::id
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
id() : _M_thread_id() { }
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class thread;
|
|
||||||
|
|
||||||
friend thread::id this_thread::get_id();
|
|
||||||
|
|
||||||
friend bool
|
|
||||||
operator==(thread::id __x, thread::id __y)
|
|
||||||
{ return __gthread_equal(__x._M_thread_id, __y._M_thread_id); }
|
|
||||||
|
|
||||||
friend bool
|
|
||||||
operator<(thread::id __x, thread::id __y)
|
|
||||||
{ return __x._M_thread_id < __y._M_thread_id; }
|
|
||||||
|
|
||||||
template<class _CharT, class _Traits>
|
|
||||||
friend basic_ostream<_CharT, _Traits>&
|
|
||||||
operator<<(basic_ostream<_CharT, _Traits>&& __out, thread::id __id);
|
|
||||||
|
|
||||||
explicit
|
|
||||||
id(__gthread_t __id)
|
|
||||||
: _M_thread_id(__id)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
__gthread_t _M_thread_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool
|
|
||||||
operator!=(thread::id __x, thread::id __y)
|
|
||||||
{ return !(__x == __y); }
|
|
||||||
|
|
||||||
inline bool
|
|
||||||
operator<=(thread::id __x, thread::id __y)
|
|
||||||
{ return !(__y < __x); }
|
|
||||||
|
|
||||||
inline bool
|
|
||||||
operator>(thread::id __x, thread::id __y)
|
|
||||||
{ return __y < __x; }
|
|
||||||
|
|
||||||
inline bool
|
|
||||||
operator>=(thread::id __x, thread::id __y)
|
|
||||||
{ return !(__x < __y); }
|
|
||||||
|
|
||||||
template<class _CharT, class _Traits>
|
|
||||||
inline basic_ostream<_CharT, _Traits>&
|
|
||||||
operator<<(basic_ostream<_CharT, _Traits>&& __out, thread::id __id)
|
|
||||||
{
|
|
||||||
if(__id == thread::id())
|
|
||||||
return __out << "non-executing thread";
|
|
||||||
else
|
|
||||||
return __out << __id._M_thread_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline thread::id
|
|
||||||
thread::get_id() const
|
|
||||||
{
|
|
||||||
if(_M_thread_data)
|
|
||||||
return thread::id(_M_thread_data->_M_thread_handle);
|
|
||||||
else
|
|
||||||
return thread::id();
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace this_thread
|
|
||||||
{
|
|
||||||
inline thread::id
|
|
||||||
get_id()
|
|
||||||
{ return thread::id(__gthread_self()); }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
|
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
|
||||||
|
@ -34,28 +34,25 @@
|
|||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
extern "C"
|
extern "C" void*
|
||||||
|
execute_native_thread_routine(void* __p)
|
||||||
{
|
{
|
||||||
void* __thread_proxy(void* __p)
|
thread::_Impl_base* __t = static_cast<thread::_Impl_base*>(__p);
|
||||||
{
|
thread::__shared_base_type __local;
|
||||||
thread::__thread_data_base* __t =
|
__local.swap(__t->_M_this_ptr);
|
||||||
static_cast<thread::__thread_data_base*>(__p);
|
|
||||||
thread::__thread_data_ptr __local_thread_data;
|
|
||||||
__local_thread_data.swap(__t->_M_this_ptr);
|
|
||||||
|
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
__local_thread_data->_M_run();
|
__local->_M_run();
|
||||||
}
|
}
|
||||||
__catch(...)
|
__catch(...)
|
||||||
{
|
{
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,41 +61,42 @@ namespace std
|
|||||||
{
|
{
|
||||||
int __e = EINVAL;
|
int __e = EINVAL;
|
||||||
|
|
||||||
if (_M_thread_data)
|
if (_M_data)
|
||||||
{
|
{
|
||||||
void* __r = 0;
|
void* __r = 0;
|
||||||
__e = __gthread_join(_M_thread_data->_M_thread_handle, &__r);
|
__e = __gthread_join(_M_data->_M_id._M_thread, &__r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__e)
|
if (__e)
|
||||||
__throw_system_error(__e);
|
__throw_system_error(__e);
|
||||||
|
|
||||||
_M_thread_data.reset();
|
_M_data.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
thread::detach()
|
thread::detach()
|
||||||
{
|
{
|
||||||
int __e = EINVAL;
|
int __e = EINVAL;
|
||||||
|
|
||||||
if (_M_thread_data)
|
if (_M_data)
|
||||||
__e = __gthread_detach(_M_thread_data->_M_thread_handle);
|
__e = __gthread_detach(_M_data->_M_id._M_thread);
|
||||||
|
|
||||||
if (__e)
|
if (__e)
|
||||||
__throw_system_error(__e);
|
__throw_system_error(__e);
|
||||||
|
|
||||||
_M_thread_data.reset();
|
_M_data.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
thread::_M_start_thread()
|
thread::_M_start_thread()
|
||||||
{
|
{
|
||||||
_M_thread_data->_M_this_ptr = _M_thread_data;
|
// _M_data->_M_this_ptr = _M_data;
|
||||||
int __e = __gthread_create(&_M_thread_data->_M_thread_handle,
|
_M_data->_M_this_ptr = _M_data;
|
||||||
&__thread_proxy, _M_thread_data.get());
|
int __e = __gthread_create(&_M_data->_M_id._M_thread,
|
||||||
|
&execute_native_thread_routine, _M_data.get());
|
||||||
if (__e)
|
if (__e)
|
||||||
{
|
{
|
||||||
_M_thread_data->_M_this_ptr.reset();
|
_M_data->_M_this_ptr.reset();
|
||||||
__throw_system_error(__e);
|
__throw_system_error(__e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc
Normal file
36
libstdc++-v3/testsuite/30_threads/thread/cons/assign_neg.cc
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// { dg-do compile }
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
// { dg-require-cstdint "" }
|
||||||
|
// { dg-require-gthreads "" }
|
||||||
|
|
||||||
|
// Copyright (C) 2009 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
// assign
|
||||||
|
typedef std::thread test_type;
|
||||||
|
test_type t1;
|
||||||
|
test_type t2;
|
||||||
|
t1 = t2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// { dg-error "used here" "" { target *-*-* } 32 }
|
||||||
|
// { dg-error "deleted function" "" { target *-*-* } 145 }
|
36
libstdc++-v3/testsuite/30_threads/thread/cons/copy_neg.cc
Normal file
36
libstdc++-v3/testsuite/30_threads/thread/cons/copy_neg.cc
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// { dg-do compile }
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
// { dg-require-cstdint "" }
|
||||||
|
// { dg-require-gthreads "" }
|
||||||
|
|
||||||
|
// Copyright (C) 2009 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
// copy
|
||||||
|
typedef std::thread test_type;
|
||||||
|
test_type t1;
|
||||||
|
test_type t2(t1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// { dg-error "here" "" { target *-*-* } 31 }
|
||||||
|
// { dg-error "deleted function" "" { target *-*-* } 124 }
|
||||||
|
// { dg-excess-errors "In file included from" }
|
38
libstdc++-v3/testsuite/30_threads/thread/id/operators.cc
Normal file
38
libstdc++-v3/testsuite/30_threads/thread/id/operators.cc
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// { dg-do compile }
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
// { dg-require-cstdint "" }
|
||||||
|
// { dg-require-gthreads "" }
|
||||||
|
|
||||||
|
// Copyright (C) 2009 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
// thread::id operators
|
||||||
|
std::thread::id id1;
|
||||||
|
std::thread::id id2;
|
||||||
|
|
||||||
|
id1 == id2;
|
||||||
|
id1 != id2;
|
||||||
|
id1 < id2;
|
||||||
|
id1 > id2;
|
||||||
|
id1 >= id2;
|
||||||
|
id1 <= id2;
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
|
||||||
|
// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
|
||||||
|
// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
|
||||||
|
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
|
||||||
|
// { dg-require-cstdint "" }
|
||||||
|
// { dg-require-gthreads "" }
|
||||||
|
|
||||||
|
// Copyright (C) 2009 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
|
// Current implementation punts on this.
|
||||||
|
VERIFY( std::thread::hardware_concurrency() == 0 );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user