2 * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 * Declaration of event abstraction.
44 /* Indicates that waiting on an event should never timeout */
45 #define EVENT_NO_TIMEOUT 0xFFFFFFFF
47 #include <complib/cl_event_osd.h>
50 # define BEGIN_C_DECLS extern "C" {
51 # define END_C_DECLS }
52 #else /* !__cplusplus */
53 # define BEGIN_C_DECLS
55 #endif /* __cplusplus */
58 /****h* Component Library/Event
63 * The Event provides the ability to suspend and wakeup a thread.
65 * The event functions operates on a cl_event_t structure which should be
66 * treated as opaque and should be manipulated only through the provided
73 * Initialization/Destruction:
74 * cl_event_construct, cl_event_init, cl_event_destroy
77 * cl_event_signal, cl_event_reset, cl_event_wait_on
79 /****f* Component Library: Event/cl_event_construct
84 * The cl_event_construct function constructs an event.
88 void cl_event_construct(IN cl_event_t * const p_event);
92 * [in] Pointer to an cl_event_t structure to construct.
95 * This function does not return a value.
98 * Allows calling cl_event_destroy without first calling cl_event_init.
100 * Calling cl_event_construct is a prerequisite to calling any other event
101 * function except cl_event_init.
104 * Event, cl_event_init, cl_event_destroy
107 /****f* Component Library: Event/cl_event_init
112 * The cl_event_init function initializes an event for use.
117 cl_event_init(IN cl_event_t * const p_event, IN const boolean_t manual_reset);
121 * [in] Pointer to an cl_event_t structure to initialize.
124 * [in] If FALSE, indicates that the event resets itself after releasing
125 * a single waiter. If TRUE, the event remains in the signalled state
126 * until explicitly reset by a call to cl_event_reset.
129 * CL_SUCCESS if event initialization succeeded.
131 * CL_ERROR otherwise.
134 * Allows calling event manipulation functions, such as cl_event_signal,
135 * cl_event_reset, and cl_event_wait_on.
137 * The event is initially in a reset state.
140 * Event, cl_event_construct, cl_event_destroy, cl_event_signal,
141 * cl_event_reset, cl_event_wait_on
144 /****f* Component Library: Event/cl_event_destroy
149 * The cl_event_destroy function performs any necessary cleanup of an event.
153 void cl_event_destroy(IN cl_event_t * const p_event);
158 * [in] Pointer to an cl_event_t structure to destroy.
161 * This function does not return a value.
164 * This function should only be called after a call to cl_event_construct
168 * Event, cl_event_construct, cl_event_init
171 /****f* Component Library: Event/cl_event_signal
176 * The cl_event_signal function sets an event to the signalled state and
177 * releases at most one waiting thread.
181 cl_status_t cl_event_signal(IN cl_event_t * const p_event);
185 * [in] Pointer to an cl_event_t structure to set.
188 * CL_SUCCESS if the event was successfully signalled.
190 * CL_ERROR otherwise.
193 * For auto-reset events, the event is reset automatically once a wait
194 * operation is satisfied.
196 * Triggering the event multiple times does not guarantee that the same
197 * number of wait operations are satisfied. This is because events are
198 * either in a signalled on non-signalled state, and triggering an event
199 * that is already in the signalled state has no effect.
202 * Event, cl_event_reset, cl_event_wait_on
205 /****f* Component Library: Event/cl_event_reset
210 * The cl_event_reset function sets an event to the non-signalled state.
214 cl_status_t cl_event_reset(IN cl_event_t * const p_event);
218 * [in] Pointer to an cl_event_t structure to reset.
221 * CL_SUCCESS if the event was successfully reset.
223 * CL_ERROR otherwise.
226 * Event, cl_event_signal, cl_event_wait_on
229 /****f* Component Library: Event/cl_event_wait_on
234 * The cl_event_wait_on function waits for the specified event to be
235 * triggered for a minimum amount of time.
240 cl_event_wait_on(IN cl_event_t * const p_event,
241 IN const uint32_t wait_us, IN const boolean_t interruptible);
245 * [in] Pointer to an cl_event_t structure on which to wait.
248 * [in] Number of microseconds to wait.
251 * [in] Indicates whether the wait operation can be interrupted
252 * by external signals.
255 * CL_SUCCESS if the wait operation succeeded in response to the event
258 * CL_TIMEOUT if the specified time period elapses.
260 * CL_NOT_DONE if the wait was interrupted by an external signal.
262 * CL_ERROR if the wait operation failed.
265 * If wait_us is set to EVENT_NO_TIMEOUT, the function will wait until the
266 * event is triggered and never timeout.
268 * If the timeout value is zero, this function simply tests the state of
271 * If the event is already on the signalled state at the time of the call
272 * to cl_event_wait_on, the call completes immediately with CL_SUCCESS.
275 * Event, cl_event_signal, cl_event_reset
279 #endif /* _CL_EVENT_H_ */