64,648
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <mutex>
using namespace std;
static std::mutex gMutex;
int main(/*int argc, char *argv[]*/)
{
gMutex.lock();
gMutex.lock();
std::cout << "hello, world" << std::endl;
gMutex.unlock();
gMutex.unlock();
return 0;
}
void
lock()
{
int __e = __gthread_mutex_lock(&_M_mutex);
// EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may)
if (__e)
__throw_system_error(__e);
}
void
lock()
{
int __e = __gthread_recursive_mutex_lock(&_M_mutex);
// EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may)
if (__e)
__throw_system_error(__e);
}
static inline int
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_lock (__mutex);
}