Conversation
74eeda4 to
0c07f13
Compare
0c07f13 to
76ad78c
Compare
| go ctx.WinningTicketHandler() | ||
| go ctx.NewTicketHandler(shutdownContext.Done()) | ||
| go ctx.SpentmissedTicketHandler(shutdownContext.Done()) | ||
| go ctx.WinningTicketHandler(shutdownContext.Done()) |
There was a problem hiding this comment.
Should be possible for each of these methods to create their own shutdownContext using withShutdownCancel, otherwise this isn't much different from what we currently have.
There was a problem hiding this comment.
It is the same. This is about readability and standardization.
There was a problem hiding this comment.
Oh, I see. We could go the extra mile and have those 3 methods and any other method that requires a context, create their own shutdownContext using withShutdownCancel. What do you think?
There was a problem hiding this comment.
hmmm, idk. Would that be better? I'll look a little more into when the other decred repo's might spawn a new context. When I say standardization, I mostly mean what wallet and dcrd are doing. I think there a lot of good ideas that have developed that we could make use of. Although this particular refactor has been around since btcd apparently, just without the context. It was just a channel at first.
decred/dcrwallet@b145868#diff-dca9e25a1ecb5a565b1bf9142c755f71
|
|
||
| // Wait for CTRL+C to signal goroutines to terminate via quit channel. | ||
| // Wait for CTRL+C to signal goroutines to terminate | ||
| <-shutdownContext.Done() |
There was a problem hiding this comment.
If my previous comment is applied, we'd only need to ctx.Wg.Wait() here without waiting for the shutdownContext to be canceled.
Actually, waiting for this shutdownContext to be canceled isn't relevant either ways, since we'll still have to wait for the waitgroup counter to return to 0; and each of the goroutines that decrement the waitgroup counter do so only after the shutdownContext is canceled.
If there's something we should do here, is make the waitgroup counter increment whenever a shutdown context is created, then ensure that each method that creates and uses a shutdown context decrements the waitgroup after performing any necessary cleanups on receiving the context cancelation signal. Then here, we only wait for the waitgroup counter to decrement to 0.
There was a problem hiding this comment.
With the latest changes which have been pushed, I think the wait for shutdownContext is now redundant and can be removed. There is no harm in keeping it there, but it is not necessary. Do you concur @itswisdomagain @JoeGruffins ?
There was a problem hiding this comment.
I like it, but it is indeed redundant. Removing...
jholdstock
left a comment
There was a problem hiding this comment.
Tested the change and this works well.
Rough rule of thumb for copyrights is to not remove or modify anything which already exists, only add "Decred Developers" and/or the current year if either are missing. Strictly speaking, this is not exactly the right thing to do because "Decred Developers" is not a well defined group and not a legal entity, however we will stick to this pattern simply because it is present in the rest of the project. Consistency is king.
Agree that we should call our Context object ctx and I see you are starting to address that in #529.
I added a comment to update the copyright, but after that is fixed I'm happy for this PR to be merged as-is. This is definitely a step forward, and consistency with other repositories is always nice. The suggestion from @itswisdomagain is interesting, I guess this can be explored in another PR, perhaps after #529.
76ad78c to
1ddef35
Compare
|
So, I went a little farther. Let me know what you think, I can always pop off the last commit. And then pass the context instead of the channel. I'm kinda torn here, as we could just pass the channel, but it doesn't hurt to pass the entire context, does it? Anyway, I like it like this. Also wires the autoreconnect to watch the shutdown context's done channel, and removes the need to call stop. |
1ddef35 to
3c0ce67
Compare
|
Not sure what this travis error is all about. Guess I'll try the open close trick later... |
|
Restarting the build won't help in this case. Go 1.13 now validates all pseudo version strings. gitea specified too much of one dep's commit hash. You'll have to put a replace statement: |
|
@chappjc Thank you!! |
50bb158 to
0b7ffff
Compare
jholdstock
left a comment
There was a problem hiding this comment.
This can go in when the conflict is resolved
A struct channel was used in order to signal shutdowns. This changes that to a context.Context that we can spawn new contexts from. Abstracts the task to a seperate file signal.go
8948c14 to
a2ca2e8
Compare
A struct channel was used in order to signal shutdowns. This changes that to a context.Context that we can spawn new contexts from. Abstracts the task to a seperate file signal.go
A struct channel was used in order to signal shutdowns. This changes that to a context.Context that we can spawn new contexts from. Abstracts the task to a seperate file signal.go
A struct channel was used in order to signal shutdowns. This changes that to a context.Context that we can spawn new contexts from. Abstracts the task to a seperate file signal.go
A struct channel was used in order to signal shutdowns. This changes
that to a context.Context that we can spawn new contexts from. Abstracts
the task to a seperate file signal.go
This is pretty much a copy/paste from dcrd and dcrwallet. This gives us a base context to spawn new contexts off of.
One difference is that the name "ctx" is taken. Can we rename all "ctx" to something else?
Also, no idea what to do with the copyrights. Help me out.