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

Replacing future wait with run loop #133

Closed
wants to merge 3 commits into from
Closed

Replacing future wait with run loop #133

wants to merge 3 commits into from

Conversation

drekka
Copy link
Contributor

@drekka drekka commented Jul 21, 2022

Pursuant to the discussion in #132 I messed about to see if I could come up with something that would allow the future to resolve and the current thread to release.

The NIO API doco actually suggests that using .wait() might not be a good idea so I decided to try replacing the promise/future with run loop execution. It worked, allowing the .start() function to throw an error if the port was not available both iOS and OSX.

However, I'm not an expert in the the NIO code or all the depths of multithreading at that level so whilst this solutions works, it may not be the best one.

All tests were run and green with this code.

Signed-off-by: Derek Clarkson <d4rkf1br3@gmail.com>
@codecov
Copy link

codecov bot commented Jul 21, 2022

Codecov Report

Merging #133 (16d1d76) into main (9eff305) will increase coverage by 0.10%.
The diff coverage is 70.00%.

❗ Current head 16d1d76 differs from pull request most recent head a640e56. Consider uploading reports for the commit a640e56 to get more accurate results

@@            Coverage Diff             @@
##             main     #133      +/-   ##
==========================================
+ Coverage   78.36%   78.46%   +0.10%     
==========================================
  Files          71       71              
  Lines        3046     3042       -4     
==========================================
  Hits         2387     2387              
+ Misses        659      655       -4     
Impacted Files Coverage Δ
Sources/Hummingbird/Application.swift 95.23% <70.00%> (+0.15%) ⬆️
...s/HummingbirdFoundation/Files/FileMiddleware.swift 87.41% <0.00%> (+0.83%) ⬆️
Sources/HummingbirdJobs/MemoryJobQueue.swift 100.00% <0.00%> (+6.45%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9eff305...a640e56. Read the comment docs.

Signed-off-by: Derek Clarkson <d4rkf1br3@gmail.com>
Signed-off-by: Derek Clarkson <d4rkf1br3@gmail.com>
@adam-fowler
Copy link
Member

This has been replaced with a semaphore in #135

@drekka
Copy link
Contributor Author

drekka commented Jul 31, 2022

Cool. That wasn't something I would have thought of as I've never had need to use a semaphore in the past. Always a chance to learn new things :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants