2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include "mf-cancel.h"
25 mf_cancel *mf_cancel_new(void)
27 mf_cancel *cancel = NULL;
29 cancel = g_new0(mf_cancel, 1);
31 cancel->is_cancel = FALSE;
32 cancel->do_cancel = FALSE;
33 g_static_mutex_init(&cancel->s_mutex);
38 void mf_cancel_free(mf_cancel *cancel)
41 cancel->is_cancel = FALSE;
42 g_static_mutex_free(&cancel->s_mutex);
47 void mf_cancel_do_cancel(mf_cancel *cancel)
50 g_static_mutex_lock(&cancel->s_mutex);
51 cancel->do_cancel = TRUE;
52 g_static_mutex_unlock(&cancel->s_mutex);
57 gboolean mf_cancel_check_cancel(mf_cancel *cancel)
59 gboolean do_cancel = FALSE;
61 g_static_mutex_lock(&cancel->s_mutex);
62 if (cancel->do_cancel)
64 g_static_mutex_unlock(&cancel->s_mutex);
70 void mf_cancel_set_cancelled(mf_cancel *cancel)
73 g_static_mutex_lock(&cancel->s_mutex);
74 cancel->is_cancel = TRUE;
75 g_static_mutex_unlock(&cancel->s_mutex);
80 gboolean mf_cancel_is_cancelled(mf_cancel *cancel)
82 gboolean is_cancelled = FALSE;
84 g_static_mutex_lock(&cancel->s_mutex);
85 if (cancel->is_cancel)
87 g_static_mutex_unlock(&cancel->s_mutex);