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

Showcase #1

Closed
wants to merge 11 commits into from
Closed

Showcase #1

wants to merge 11 commits into from

Conversation

NYBACHOK
Copy link
Collaborator

No description provided.


let _ = thread::spawn( move || {
loop {
let (stream, addr) = self.listener.accept().map_err(Error::io).expect( "failed to accept connection");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we expect now instead of returning the error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Cause of this line of code. It blocks the main thread and I chose to move it into a separate thread.
What do you think:

  1. Call expect on error
  2. Send error with mpsc
  3. Ignore error and log it
  4. Don't panic but request cancellation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I think. Approach with logging error and stopping application better

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed


});

while !CancellationSource::is_cancelled() { }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to consume the CPU?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I need to add thread::sleep

@NYBACHOK NYBACHOK closed this Jun 28, 2024
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.

2 participants