NicoNex / echotron

An elegant and concurrent library for the Telegram bot API in Go.
https://t.me/s/echotronnews
GNU Lesser General Public License v3.0
363 stars 26 forks source link

move mutex unlock before bot update goroutine #12

Closed Masynchin closed 3 years ago

Masynchin commented 3 years ago

Hello! I am new to Go and currently learning it by reading the source code. I love coding async bots on Python and now want to do almost the same with goroutines. I spot that mutex unlock call is after goroutine, isn't it bad? If it isn't, can you explain me why? Thanks for the library!

NicoNex commented 3 years ago

@Masynchin Thank you for spotting the issue and sorry for the wait. The difference between the two implementations is almost negligible, but it might still improve the execution time by a tiny bit so I'm going to merge it.

Also, happy to hear that you're learning Go! I think it's a great programming language, especially for concurrency. Keep up with the bot development and we'd be happy to hear which awesome bots you'll develop with echotron!

Masynchin commented 3 years ago

Keep up with the bot development and we'd be happy to hear which awesome bots you'll develop with echotron!

Thanks, I just made my first bot with echotron. Is there a way to graceful shutdown dispatcher? Currently I use CTRL+C as bot closing option

DjMike238 commented 3 years ago

Is there a way to graceful shutdown dispatcher? Currently I use CTRL+C as bot closing option

No, there is no way to gracefully shut the dispatcher down. Ctrl+C should work just fine, afaik.