Skip to content

Better infinity mode implementation#16

Merged
yuhan6665 merged 3 commits into
XTLS:mainfrom
juzeon:patch-infinity
Feb 12, 2024
Merged

Better infinity mode implementation#16
yuhan6665 merged 3 commits into
XTLS:mainfrom
juzeon:patch-infinity

Conversation

@juzeon

@juzeon juzeon commented Feb 12, 2024

Copy link
Copy Markdown
Contributor

This PR introduces a better infinity mode implementation using channels instead of mutex locks.

Please take a look. Really appreciated for all your works :)

Comment thread utils.go
Type: HostTypeIP,
}
for i := 0; i < math.MaxInt; i++ {
if i%2 == 0 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your code. I was thinking about using channel this way. But I was worry about grow memory too fast. Isn't all these ips not yet processed in channel taking memory?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So it's an unbuffered channel for hostChan. It will block at the sending action until a scanning goroutine picks one away from it. Not consuming memory more than 1 Host instance.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I understand now. It is indeed better. Thanks again!

@yuhan6665 yuhan6665 merged commit 91ff827 into XTLS:main Feb 12, 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