示例#1
0
文件: wait.c 项目: 0ostreamo0/mono
static gboolean test_and_own (guint32 numobjects, gpointer *handles,
			      gboolean waitall, guint32 *count,
			      guint32 *lowest)
{
	gboolean done;
	int i;
	
	MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: locking handles", __func__);
	
	done = _wapi_handle_count_signalled_handles (numobjects, handles,
						     waitall, count, lowest);
	if (done == TRUE) {
		if (waitall == TRUE) {
			for (i = 0; i < numobjects; i++) {
				own_if_signalled (handles[i]);
			}
		} else {
			own_if_signalled (handles[*lowest]);
		}
	}
	
	MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking handles", __func__);

	_wapi_handle_unlock_handles (numobjects, handles);

	return(done);
}
示例#2
0
static gboolean test_and_own (guint32 numobjects, gpointer *handles,
			      gboolean waitall, guint32 *count,
			      guint32 *lowest)
{
	struct handle_cleanup_data cleanup_data;
	gboolean done;
	int i;
	
#ifdef DEBUG
	g_message ("%s: locking handles", __func__);
#endif
	cleanup_data.numobjects = numobjects;
	cleanup_data.handles = handles;
	
	pthread_cleanup_push (handle_cleanup, (void *)&cleanup_data);
	done = _wapi_handle_count_signalled_handles (numobjects, handles,
						     waitall, count, lowest);
	if (done == TRUE) {
		if (waitall == TRUE) {
			for (i = 0; i < numobjects; i++) {
				own_if_signalled (handles[i]);
			}
		} else {
			own_if_signalled (handles[*lowest]);
		}
	}
	
#ifdef DEBUG
	g_message ("%s: unlocking handles", __func__);
#endif

	/* calls the unlock function */
	pthread_cleanup_pop (1);

	return(done);
}