Hello,
The goal is to run in a separate thread function downloads data from the main form.
To do this, use GIOScheduler.
I have function for loading data:
void load(GInputStream* input_stream, GCancellable* cancellable)
{
...
}
The function load works 100%. Then there is the function you want to send in a separate thread:
void loading(MainWin* mw)
{
GInputStream* input_stream = g_file_read(loading_file, mw->generator_cancellable, NULL);
mw->data = load(G_INPUT_STREAM(input_stream), mw->generator_cancellable);
}
I'm trying to send the following:
g_io_scheduler_push_job( job_func1, mw, NULL, G_PRIORITY_DEFAULT, mw->generator_cancellable);
Where job_func1:
static void job_func1(GIOSchedulerJob *job, GCancellable *cancellable, gpointer user_data)
{
MainWin* mw = (MainWin*)user_data;
while(!g_cancellable_is_cancelled(mw->generator_cancellable))
{
g_io_scheduler_job_send_to_mainloop(job, loading, mw, NULL);
}
}
When i try to call loading in another thread i have big mem leak. What's wrong?
Thank you