runtime: fix some subtle event bugs.
This patch fix the following two bugs in event handling.
1. When it's time to call a event's user call back function, we need to
set the executed to true before the call. As that call back function
may call into clReleaseEvent(), and if we don't set the executed status
to true, it will enter infinite recursive loop.
2. After the user call clEnqueueNDRangeKernel to get a valid event, the
user set a call back function to that event, and in that call back
function, it will release that event. This scenario is totally correct.
But our current event handling doesn't have a deadicated timer thread to
update those on-the-fly events' status. Thus those events will not have
a chance to get updated, and those call back function will not executed
forever. To introduce a complete timer style thread to maintain this type
of events is too heavy for this fix release. This patch choose an easy
way to work around it. It will make sure the last gpgpu event to be finished
before current task to be enqueued.
After this patch, most of the OpenCV 3.0 cases could run smoothly without
any serious issue.
Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>