source: svn/trunk/newcon3bcm2_21bu/magnum/basemodules/kni/linuxuser/bkni_event_group.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 5.9 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2009, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bkni_event_group.h $
11 * $brcm_Revision: Hydra_Software_Devel/4 $
12 * $brcm_Date: 4/27/09 11:36a $
13 *
14 * Module Description:
15 *
16 * Implementatation of the Magnum KNI for user space Linux applications.
17 *
18 * Revision History:
19 *
20 * $brcm_Log: /magnum/basemodules/kni/linuxuser/bkni_event_group.h $ *
21 *
22 * Hydra_Software_Devel/4   4/27/09 11:36a haisongw
23 * PR54625:support C++ compiler in bkni_event_group.h
24 *
25 * Hydra_Software_Devel/3   2/26/04 12:29p erickson
26 * PR9736: fixed comment
27 *
28 * Hydra_Software_Devel/2   2/26/04 12:21p erickson
29 * PR9736: updated comments
30 *
31 * Hydra_Software_Devel/1   2/11/04 10:52p vsilyaev
32 * PR 9736: API for event multiplexing
33 *
34 ***************************************************************************/
35#ifndef BKNI_EVENT_GROUP_H_
36#define BKNI_EVENT_GROUP_H_
37
38#include "bkni_multi.h"
39
40/*=*************************************************************************
41Summary:
42The event group implements event multiplexing. An application
43can group multiple events and then wait in the single thread any of these
44events to be set.
45
46The BKNI_EventGroup kernel interface is an optional component of the kernel interface.
47It shall not be used by the porting interface, base modules or common utilites.
48It is only for application needs.
49
50Example:
51  #include "bkni_event_group.h"
52
53  ...
54  BKNI_EventHandle event1, event2;
55  BKNI_EventHandle events[2];
56  unsigned nevents;
57
58  BKNI_EventGroupHandle group;
59
60  BKNI_CreateEvent(&event1);
61  BKNI_CreateEvent(&event2);
62
63  BKNI_CreateEventGroup(&group);
64
65  BKNI_AddEventGroup(group, event1);
66  BKNI_AddEventGroup(group, event2);
67
68  BKNI_WaitForGroup(group, 1000, events, 2, &nevents);
69
70  printf("Got %d events", nevents);
71
72
73****************************************************************************/
74
75
76/**************************************************************************
77Summary:
78 Event group handle
79**************************************************************************/
80typedef struct BKNI_GroupObj *BKNI_EventGroupHandle;
81#ifdef __cplusplus
82extern "C" {
83#endif
84
85/**************************************************************************
86Summary:
87 This function is used to create a new event group
88
89Description:
90 This function create a new evetn group
91
92Returns:
93        BERR_SUCCESS - Event groupt was created successfully.
94        BERR_OS_ERROR - The system failed and group wasn't created
95**************************************************************************/
96BERR_Code BKNI_CreateEventGroup(
97                BKNI_EventGroupHandle *pGroup
98                );
99
100/**************************************************************************
101Summary:
102 This function is used to destroy an event group
103
104Description:
105 This function destroy a new evetn group.
106Note: application shall not be inside BKNI_WaitForGroup while calling this function.
107
108Returns:
109  N/A
110**************************************************************************/
111void BKNI_DestroyEventGroup(
112                BKNI_EventGroupHandle group
113                );
114
115/**************************************************************************
116Summary:
117 This function is used to add an event into the event group
118
119Description:
120 This function adds an event into the event group. If event is already
121 set off, active BKNI_WaitForGroup would be woken up immediatly.
122
123Note: Event could belong only to the one group at the time.
124
125Returns:
126        BERR_SUCCESS - Event was added into the group successfully
127        BERR_OS_ERROR - The system failed and event wasn't added
128**************************************************************************/
129BERR_Code
130BKNI_AddEventGroup(
131                BKNI_EventGroupHandle group,  /* Event group */
132                BKNI_EventHandle event /* Event to add into the group */
133                );
134
135/**************************************************************************
136Summary:
137 This function is used to remove an event from the event group
138
139Description:
140 This function removes to event from the event group
141
142Returns:
143        BERR_SUCCESS - Event was removed from the group successfully
144        BERR_OS_ERROR - The system failed and the group state is unspecified
145**************************************************************************/
146BERR_Code
147BKNI_RemoveEventGroup(
148                BKNI_EventGroupHandle group,  /* Event group */
149                BKNI_EventHandle event /* Event to remove from the group */
150                );
151
152/**************************************************************************
153Summary:
154 This function is used to wait for the any event from the group.
155
156Description:
157 This function waits for the any event from the group. This function
158 could exit either because of timeout, or when some event[s] are set.
159 In the latter case it would save the number of events and events themselves in
160 the events structure.
161 After the event is saved in the user specified area, the event is cleared out.
162
163Returns:
164        BERR_SUCCESS - Event was removed from the group successfully
165        BERR_OS_ERROR - The system failed and the group state is unspecified
166**************************************************************************/
167BERR_Code
168BKNI_WaitForGroup(
169                BKNI_EventGroupHandle group, /* event group */
170                int timeoutMsec,  /* timeout in milliseconds, use BKNI_INFINITE to wait without timeout */
171                BKNI_EventHandle *events, /* [out] pass out the events that were triggered
172                                                        (specified by *nevents) */
173                unsigned max_events,  /* the maximum number of events which can be passed out using
174                                                        the events parameter. Generally this should be equal to the
175                                                        number of events in the BKNI_EventGroup. */
176                unsigned *nevents /* [out] number of events which were stored in the user specified area */
177                );
178
179#ifdef __cplusplus
180}
181#endif
182#endif /* BKNI_EVENT_GROUP_H_ */
183
184
Note: See TracBrowser for help on using the repository browser.