tags:

views:

16

answers:

1

Hello,

I have foowing code fo runing function in another thread:

void load (....)
{
    GIOSchedulerJob *job;
    g_io_scheduler_job_send_to_mainloop(job,(GSourceFunc)job_func,&param, g_free);
}

    gboolean job_func(GIOSchedulerJob *job, GSourceFunc func, gpointer user_data, GDestroyNotify notify)
    {       
        JobParam* job_param = (JobParam*)user_data; 
        build(job_param->widget, job_param->mw);
        return TRUE;
    }

But when i try to call g_io_scheduler_job_send_to_mainloop i get error: g_io_scheduler_job_send_to_mainloop: assertion 'job != NULL' failed.

How can i initialize job? Or how can i fix it?

Thank you.

+1  A: 

Since the is obviously related to your previous question C attempt to difference a generic pointer

I'm going to say I think you're using the GIO job mechanism wrong (and using it for the wrong reasons as well), if you give some more detail about what you are trying to do and WHY you want to do it async someone might be able to give you a better answer, if you're still doing the same thing in build() you were before, that's STILL a problem with your code, if you're leaving things out of the code you posted, please put some comments in explaining vaguely what it would have been doing.

You haven't really given enough detail to give a proper answer. (and your code this time around seems to be LESS correct than last time)

g_io_scheduler_job_send_to_mainloop is to push a bit of work that needs to be done on the main thread, as part of a job that is already in progress, the GIOSchedulerJob is passed to your load(); by GIO when you kick of some async work with g_io_scheduler_push_job(). For example load could be something like:

gboolean load(GIOSchedulerJob *job, GCancellable *cancellable, gpointer user_data)
{
    // load a bunch of data and stuff it into param, or wherever

    g_io_scheduler_job_send_to_mainloop(job,(GSourceFunc)job_func, &param, g_free);
    return TRUE;
}

gboolean job_func(gpointer user_data)
{       
    JobParam* job_param = (JobParam*)user_data; 
    build(job_param->widget, job_param->mw);
    return TRUE;
}

But fundamentally you are using the API wrong, job_func() shouldn't have the same type as g_io_scheduler_job_send_to_mainloop()

Also this didn't really need to be a new question, you could have edited your previous one.

Spudd86
Thank you for help
shk
@sterh no problem
Spudd86