Пример #1
0
static void wm_job_main_thread_yield(wmJob *wm_job)
{
	/* unlock and lock the ticket mutex. because it's a fair mutex any job that
	 * is waiting to acquire the lock will get it first, before we can lock */
	BLI_ticket_mutex_unlock(wm_job->main_thread_mutex);
	BLI_ticket_mutex_lock(wm_job->main_thread_mutex);
}
Пример #2
0
void WM_job_main_thread_lock_acquire(wmJob *wm_job)
{
	BLI_ticket_mutex_lock(wm_job->main_thread_mutex);

	/* if BLI_end_threads is being called to stop the job before it's finished,
	 * we no longer need to lock to get access to the main thread as it's
	 * waiting and can't respond */
	if (wm_job->main_thread_mutex_ending)
		BLI_ticket_mutex_unlock(wm_job->main_thread_mutex);
}
Пример #3
0
/* every owner only gets a single job, adding a new one will stop running job and 
 * when stopped it starts the new one */
wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type)
{
	wmJob *wm_job = wm_job_find(wm, owner, job_type);
	
	if (wm_job == NULL) {
		wm_job = MEM_callocN(sizeof(wmJob), "new job");

		BLI_addtail(&wm->jobs, wm_job);
		wm_job->win = win;
		wm_job->owner = owner;
		wm_job->flag = flag;
		wm_job->job_type = job_type;
		BLI_strncpy(wm_job->name, name, sizeof(wm_job->name));

		wm_job->main_thread_mutex = BLI_ticket_mutex_alloc();
		BLI_ticket_mutex_lock(wm_job->main_thread_mutex);
	}
	/* else: a running job, be careful */
	
	/* prevent creating a job with an invalid type */
	BLI_assert(wm_job->job_type != WM_JOB_TYPE_ANY);

	return wm_job;
}
Пример #4
0
void WM_job_main_thread_lock_acquire(wmJob *wm_job)
{
	BLI_ticket_mutex_lock(wm_job->main_thread_mutex);
}