source: box/trunk/lib/server/OverlappedIO.h @ 2313

Revision 2313, 934 bytes checked in by chris, 4 years ago (diff)

Utility classes to be used by new Windows named pipe framework.

Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    OverlappedIO.h
5//              Purpose: Windows overlapped IO handle guard
6//              Created: 2008/09/30
7//
8// --------------------------------------------------------------------------
9
10#ifndef OVERLAPPEDIO__H
11#define OVERLAPPEDIO__H
12
13class OverlappedIO
14{
15public:
16        OVERLAPPED mOverlapped;
17
18        OverlappedIO()
19        {
20                ZeroMemory(&mOverlapped, sizeof(mOverlapped));
21                mOverlapped.hEvent = CreateEvent(NULL, TRUE, FALSE,
22                        NULL);
23                if (mOverlapped.hEvent == INVALID_HANDLE_VALUE)
24                {
25                        BOX_LOG_WIN_ERROR("Failed to create event for "
26                                "overlapped I/O");
27                        THROW_EXCEPTION(ServerException, BadSocketHandle);
28                }
29        }
30
31        ~OverlappedIO()
32        {
33                if (CloseHandle(mOverlapped.hEvent) != TRUE)
34                {
35                        BOX_LOG_WIN_ERROR("Failed to delete event for "
36                                "overlapped I/O");
37                        THROW_EXCEPTION(ServerException, BadSocketHandle);
38                }
39        }
40};
41
42#endif // !OVERLAPPEDIO__H
Note: See TracBrowser for help on using the repository browser.