File tree Expand file tree Collapse file tree 4 files changed +16
-20
lines changed
Expand file tree Collapse file tree 4 files changed +16
-20
lines changed Original file line number Diff line number Diff line change @@ -13,4 +13,9 @@ if(UNIX AND NOT APPLE)
1313 target_link_libraries (slick_queue INTERFACE rt)
1414endif ()
1515
16- add_subdirectory (tests EXCLUDE_FROM_ALL )
16+ if (WIN32 )
17+ add_subdirectory (tests)
18+ else ()
19+ add_subdirectory (tests EXCLUDE_FROM_ALL )
20+ endif ()
21+
Original file line number Diff line number Diff line change @@ -194,10 +194,14 @@ class SlickQueue {
194194
195195#if defined(_MSC_VER)
196196 void allocate_shm_data (const char * const shm_name, bool open_only) {
197- SIZE_T BF_SZ = 64 + sizeof (slot) * size_ + sizeof (T) * size_;
197+ DWORD BF_SZ = 64 + sizeof (slot) * size_ + sizeof (T) * size_;
198198 hMapFile_ = NULL ;
199199 if (open_only) {
200+ #ifndef UNICODE
201+ hMapFile_ = OpenFileMapping (FILE_MAP_ALL_ACCESS, FALSE , (LPCSTR)shm_name);
202+ #else
200203 hMapFile_ = OpenFileMapping (FILE_MAP_ALL_ACCESS, FALSE , (LPCWSTR)shm_name);
204+ #endif
201205 own_ = false ;
202206 auto err = GetLastError ();
203207 if (hMapFile_ == NULL ) {
@@ -220,8 +224,12 @@ class SlickQueue {
220224 NULL , // default security
221225 PAGE_READWRITE, // read/write access
222226 0 , // maximum object size (high-order DWORD)
223- BF_SZ, // maximum object size (low-order DWORD)
227+ BF_SZ, // maximum object size (low-order DWORD)
228+ #ifndef UNICODE
229+ (LPCSTR)shm_name // name of mapping object
230+ #else
224231 (LPCWSTR)shm_name // name of mapping object
232+ #endif
225233 );
226234
227235 own_ = false ;
Original file line number Diff line number Diff line change 1- project (slick_queue_tests LANGUAGES CXX)
2-
3- set (CMAKE_CXX_STANDARD 17)
4-
51add_executable (slick_queue_tests tests.cpp shm_tests.cpp)
62
73target_link_libraries (slick_queue_tests PRIVATE slick_queue)
Original file line number Diff line number Diff line change @@ -71,16 +71,3 @@ TEST_CASE( "Publish and read multiple - shm" ) {
7171 REQUIRE (read_cursor == 3 );
7272 REQUIRE (*read.first == 23 );
7373}
74-
75- TEST_CASE (" SHM test - shm" ) {
76- SlickQueue<int > queue (2 , " sq_shm_test" );
77- uint64_t read_cursor = 0 ;
78- auto reserved = queue.reserve ();
79- *queue[reserved] = 5 ;
80- queue.publish (reserved);
81- auto read = queue.read (read_cursor);
82- REQUIRE (read.first != nullptr );
83- REQUIRE (read_cursor == 1 );
84- REQUIRE (*read.first == 5 );
85- }
86-
You can’t perform that action at this time.
0 commit comments