static gboolean emit_select_callback_in_idle (gpointer user_data) { CallbackData *data = user_data; if (!data->aborted) data->callback (&data->rectangle, data->callback_data); else data->callback (NULL, data->callback_data); g_slice_free (CallbackData, data); return FALSE; }
bool SBBreakpoint::PrivateBreakpointHitCallback(void *baton, StoppointCallbackContext *ctx, lldb::user_id_t break_id, lldb::user_id_t break_loc_id) { ExecutionContext exe_ctx (ctx->exe_ctx_ref); BreakpointSP bp_sp(exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id)); if (baton && bp_sp) { CallbackData *data = (CallbackData *)baton; lldb_private::Breakpoint *bp = bp_sp.get(); if (bp && data->callback) { Process *process = exe_ctx.GetProcessPtr(); if (process) { SBProcess sb_process (process->shared_from_this()); SBThread sb_thread; SBBreakpointLocation sb_location; assert (bp_sp); sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id)); Thread *thread = exe_ctx.GetThreadPtr(); if (thread) sb_thread.SetThread(thread->shared_from_this()); return data->callback (data->callback_baton, sb_process, sb_thread, sb_location); } } } return true; // Return true if we should stop at this breakpoint }
/****************************************************************************** * void Event::setCallback ******************************************************************************/ void Event::setCallback(cl_int command_exec_callback_type, event_callback callback, void *user_data) { CallbackData data; bool call_now = false; data.callback = callback; data.user_data = user_data; pthread_mutex_lock(&p_state_mutex); /* if event already in or past command_exec_callback_type, call callback */ /* cl.h: CL_COMPLETE 0, CL_RUNNING 1, CL_SUBMITTED 2, CL_QUEUED 3 */ if (command_exec_callback_type >= p_status) call_now = true; else p_callbacks.insert(std::pair<Status, CallbackData>( (Status)command_exec_callback_type, data) ); pthread_mutex_unlock(&p_state_mutex); if (call_now) data.callback(desc(this), p_status, data.user_data); }