1 /* *****************************************************************
3 * Copyright 2017 Microsoft
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ******************************************************************/
23 * This file defines the event object.
35 #endif /* __cplusplus */
37 typedef struct oc_event_t *oc_event;
40 * Creates a new event.
42 * @return Reference to newly created event, NULL on allocation failure.
44 oc_event oc_event_new(void);
49 * @param[in] event Optional event to be freed.
51 void oc_event_free(oc_event event);
54 * Waits infinitely for the event to be signaled.
56 * @param[in] event Event to wait on.
58 void oc_event_wait(oc_event event);
61 * Waits for the event to be signaled or timed out.
63 * @param[in] event Event to wait on.
64 * @param[in] milliseconds Timeout in milliseconds.
65 * @return OC_WAIT_SUCCESS Event was signaled before timeout expired.
66 * OC_WAIT_TIMEDOUT Timeout interval elapsed.
68 OCWaitResult_t oc_event_wait_for(oc_event event, uint32_t milliseconds);
73 * @param[in] event Event to signal.
75 void oc_event_signal(oc_event event);
79 #endif /* __cplusplus */
81 #endif /* OC_EVENT_H_ */