如何在Vista / Server 2008上使用std :: shared_mutex? [英] How to use std::shared_mutex on Vista/Server 2008?

查看:96
本文介绍了如何在Vista / Server 2008上使用std :: shared_mutex?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 TryAcquireSRWLock *和_WIN32_WINNT 的后续问题

This is a follow-up question to TryAcquireSRWLock* and _WIN32_WINNT

似乎Windows SDK 8.1和更高版本(至少到当前的10.0.16299.0)中存在错误,使得方法 TryAcquireSRWLockShared TryAcquireSRWLockExclusive 可用于针对Windows Vista或Windows Server 2008的编译。这导致包含对这些方法的调用的应用程序无法在Windows Vista或Windows Server 2008上执行最终只能从Windows 7或Windows Server 2008 R2开始使用。

As it seems there is a bug in the Windows SDK 8.1 and newer (up to at least the current 10.0.16299.0) making the methods TryAcquireSRWLockShared and TryAcquireSRWLockExclusive available for compilations targeting Windows Vista or Windows Server 2008. This causes applications containing calls to these methods being unable to execute on Windows Vista or Windows Server 2008 since they are ultimately only available starting from Windows 7 or Windows Server 2008 R2.

似乎 std :: shared_mutex < Windows SDK 8.1中的/ a>使用 TryAcquireSRWLockShared 和< a href = https://msdn.microsoft.com/zh-CN/library/windows/desktop/dd405523(v=vs.85).aspx rel = nofollow noreferrer> TryAcquireSRWLockExclusive 。因此,使用 std :: shared_mutex 会使应用程序无法可以在Windows Vista或Windows Server 2008上执行。

It seems that the implementation of std::shared_mutex in the Windows SDK 8.1 makes use of TryAcquireSRWLockShared and TryAcquireSRWLockExclusive. Thus using std::shared_mutex renders the application unable to execute on Windows Vista or Windows Server 2008.

文档还指出


警告

Warning

从Visual Studio 2015开始,C ++标准库
同步类型基于Windows同步原语
,并且不再使用ConcRT(除非当目标平台是Windows
XP时)。在< shared_mutex>中定义的类型。不应与任何
ConcRT类型或函数一起使用。

Beginning in Visual Studio 2015, the C++ Standard Library synchronization types are based on Windows synchronization primitives and no longer use ConcRT (except when the target platform is Windows XP). The types defined in <shared_mutex> should not be used with any ConcRT types or functions.

但是,当使用平台工具集v140_xp时,编译器会抱怨完全不了解 std :: shared_mutex

However, when using the platform toolset v140_xp the compiler complains about not knowing std::shared_mutex at all.

如何使用 std :: shared_mutex 并仍然以Windows Vista或Windows Server 2008为目标?

How can I use std::shared_mutex and still target Windows Vista or Windows Server 2008?

推荐答案

我认为您不能。但是您可以使用其他实现。 boost :: shared_mutex 。或者,如果您使用的是Qt,则可以使用QReadWriteLock。

I think you can't. But you can use alternate implementations. There's boost::shared_mutex. Or if you are using Qt, you can use QReadWriteLock.

这篇关于如何在Vista / Server 2008上使用std :: shared_mutex?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆