Skip to content

Explicit Call to spdlog::shutdown Required? #2685

Answered by tt4g
mattbrown015 asked this question in Q&A
Discussion options

You must be logged in to vote

Should I add spdlog::shutdown to the end of main in a multithreaded application?

We use spdlog as a shared library. The application runs on Windows and Linux.

Yes.
spdlog creates a thread pool for the async logger.
It is recommended to call spdlog::shutdown() as it destroys the thread pool.

And spdlog::shutdown() calls sink's flush operation. This operation is important on Windows because Windows discards the data remaining in the I/O buffer after main().

However, I will tell you that it is important to properly clean up all threads of your application.
This is because std::thread calls std::thread::terminate() in the destructor unless std::thread::join() or std::thread::detach() is cal…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@mattbrown015
Comment options

Answer selected by mattbrown015
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants