本文整理汇总了C++中Condition::GetHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ Condition::GetHandle方法的具体用法?C++ Condition::GetHandle怎么用?C++ Condition::GetHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Condition
的用法示例。
在下文中一共展示了Condition::GetHandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteSocket
bool Helium::WriteSocket(Socket& socket, void* buffer, uint32_t bytes, uint32_t& wrote, Condition& terminate, sockaddr_in *peer)
{
CheckPeerParamCompatibleWithProtocol(static_cast<Helium::SocketProtocol>(socket.m_Protocol), peer);
if (bytes == 0)
{
return true;
}
WSABUF buf;
buf.buf = (CHAR*)buffer;
buf.len = bytes;
DWORD flags = 0;
DWORD wrote_local = 0;
int wsa_result = peer ? ::WSASendTo(socket.m_Handle, &buf, 1, &wrote_local, 0, (SOCKADDR *)peer, sizeof(sockaddr_in), (OVERLAPPED*)&socket.m_Overlapped, NULL) :
::WSASend (socket.m_Handle, &buf, 1, &wrote_local, 0, (OVERLAPPED*)&socket.m_Overlapped, NULL);
if ( wsa_result != 0 )
{
int last_error = WSAGetLastError();
if ( WSAGetLastError() != WSA_IO_PENDING )
{
#ifdef IPC_DEBUG_SOCKETS
Helium::Print("Socket Support: Failed to initiate overlapped write (%s)\n", Helium::GetErrorString().c_str());
#endif
return false;
}
else
{
HANDLE events[] = { terminate.GetHandle(), socket.m_Overlapped.hEvent };
DWORD result = ::WSAWaitForMultipleEvents(2, events, FALSE, INFINITE, FALSE);
HELIUM_ASSERT( result != WAIT_FAILED );
if ( (result - WAIT_OBJECT_0) == 0 )
{
#ifdef IPC_DEBUG_SOCKETS
Helium::Print("Socket Support: Terminating write\n");
#endif
return false;
}
if ( !::WSAGetOverlappedResult(socket.m_Handle, (OVERLAPPED*)&socket.m_Overlapped, &wrote_local, false, &flags) )
{
#ifdef IPC_DEBUG_SOCKETS
Helium::Print("Socket Support: Failed write (%s)\n", Helium::GetErrorString().c_str());
#endif
return false;
}
}
}
if (wrote_local == 0)
{
return false;
}
wrote = (uint32_t)wrote_local;
return true;
}