io_thread: add function io_thread_quit()

This commit is contained in:
Max Kellermann 2011-08-29 09:44:08 +02:00
parent a97ddc8cb9
commit 4733c5fef0
2 changed files with 17 additions and 2 deletions

View File

@ -74,13 +74,20 @@ io_thread_start(GError **error_r)
return true; return true;
} }
void
io_thread_quit(void)
{
assert(io.loop != NULL);
g_main_loop_quit(io.loop);
}
void void
io_thread_deinit(void) io_thread_deinit(void)
{ {
if (io.thread != NULL) { if (io.thread != NULL) {
assert(io.loop != NULL); io_thread_quit();
g_main_loop_quit(io.loop);
g_thread_join(io.thread); g_thread_join(io.thread);
} }

View File

@ -37,6 +37,14 @@ io_thread_start(GError **error_r);
void void
io_thread_run(void); io_thread_run(void);
/**
* Ask the I/O thread to quit, but does not wait for it. Usually, you
* don't need to call this function, because io_thread_deinit()
* includes this.
*/
void
io_thread_quit(void);
void void
io_thread_deinit(void); io_thread_deinit(void);