Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add native semaphore implementation #25

Merged
merged 14 commits into from Aug 6, 2019

Conversation

@yohhoy
Copy link
Owner

yohhoy commented Aug 3, 2019

  • support GCD dispatch semaphore (macOS/iOS)
  • support POSIX semaphore
  • support Windows semaphore
  • update README
@yohhoy

This comment has been minimized.

Copy link
Owner Author

yohhoy commented Aug 6, 2019

yamc::win::counting_semaphore<> timeout tests frequently failed, because underlying WaitForSingleObject function will return early than specified timeout interval by Design.

Wait Functions and Time-out Intervals
The accuracy of the specified time-out interval depends on the resolution of the system clock. The system clock "ticks" at a constant rate. If the time-out interval is less than the resolution of the system clock, the wait may time out in less than the specified length of time. If the time-out interval is greater than one tick but less than two, the wait can be anywhere between one and two ticks, and so on.


These cases expects 300 milliseconds timeout, but actual interval are from 289.494 to 297.561 milliseconds.

https://ci.appveyor.com/project/yohhoy/yamc/builds/26471133/job/uoh06441a5dmt1u5#L837

[ RUN      ] SemaphoreTest/1.TryAcquireForTimeout
C:\projects\yamc\tests\semaphore_test.cpp(167): error: Expected: (std::chrono::milliseconds(300)) <= (sw.elapsed()), actual: 8-byte object <2C-01 00-00 00-00 00-00> vs 8-byte object <71-6B 04-00 00-00 00-00>
[  FAILED  ] SemaphoreTest/1.TryAcquireForTimeout, where TypeParam = struct WinSemaphore (291 ms)

https://ci.appveyor.com/project/yohhoy/yamc/builds/26470639/job/2jj9vpcj6ccfaoke#L803

[ RUN      ] SemaphoreTest/1.TryAcquireForTimeout
C:\projects\yamc\tests\semaphore_test.cpp(167): error: Expected: (std::chrono::milliseconds(300)) <= (sw.elapsed()), actual: 8-byte object <2C-01 00-00 00-00 00-00> vs 8-byte object <59-8A 04-00 00-00 00-00>
[  FAILED  ] SemaphoreTest/1.TryAcquireForTimeout, where TypeParam = struct WinSemaphore (298 ms)

https://ci.appveyor.com/project/yohhoy/yamc/builds/26470640/job/h7jcou6sdsdmmkey#L804

[ RUN      ] SemaphoreTest/1.TryAcquireForTimeout
C:\projects\yamc\tests\semaphore_test.cpp(167): error: Expected: (std::chrono::milliseconds(300)) <= (sw.elapsed()), actual: 8-byte object <2C-01 00-00 00-00 00-00> vs 8-byte object <44-8A 04-00 00-00 00-00>
[  FAILED  ] SemaphoreTest/1.TryAcquireForTimeout, where TypeParam = struct WinSemaphore (298 ms)

https://ci.appveyor.com/project/yohhoy/yamc/builds/26465767/job/b4lix5h2wryt3ywg#L803

[ RUN      ] SemaphoreTest/1.TryAcquireForTimeout
C:\projects\yamc\tests\semaphore_test.cpp(167): error: Expected: (std::chrono::milliseconds(300)) <= (sw.elapsed()), actual: 8-byte object <2C-01 00-00 00-00 00-00> vs 8-byte object <F9-89 04-00 00-00 00-00>
[  FAILED  ] SemaphoreTest/1.TryAcquireForTimeout, where TypeParam = struct WinSemaphore (298 ms)

https://ci.appveyor.com/project/yohhoy/yamc/builds/26458440/job/ipwpe0pijt0t06sh#L837

[ RUN      ] SemaphoreTest/1.TryAcquireForTimeout
C:\projects\yamc\tests\semaphore_test.cpp(167): error: Expected: (std::chrono::milliseconds(300)) <= (sw.elapsed()), actual: 8-byte object <2C-01 00-00 00-00 00-00> vs 8-byte object <F6-83 04-00 00-00 00-00>
[  FAILED  ] SemaphoreTest/1.TryAcquireForTimeout, where TypeParam = struct WinSemaphore (297 ms)
yohhoy added 2 commits Aug 6, 2019
use Sleep(1) to guarantee timing specification in C++ Standard,
instead of additional timeout offset for WaitForSingleObject().
@yohhoy yohhoy added the enhancement label Aug 6, 2019
@yohhoy yohhoy merged commit 374a793 into master Aug 6, 2019
4 checks passed
4 checks passed
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@yohhoy yohhoy deleted the native-sem branch Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.