Make OCProcessEvent method.
[platform/upstream/iotivity.git] / resource / c_common / ocevent / include / ocevent.h
1 /* *****************************************************************
2  *
3  * Copyright 2017 Microsoft
4  *
5  *
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  ******************************************************************/
19
20 /**
21  * @file
22  *
23  * This file defines the event object.
24  */
25
26 #ifndef OC_EVENT_H_
27 #define OC_EVENT_H_
28
29 #include "octhread.h"
30 #include <stdint.h>
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif /* __cplusplus */
36
37 typedef struct oc_event_t *oc_event;
38
39 /**
40  * Creates a new event.
41  *
42  * @return  Reference to newly created event, NULL on allocation failure.
43  */
44 oc_event oc_event_new(void);
45
46 /**
47  * Frees the oc_event.
48  *
49  * @param[in]  event  Optional event to be freed.
50  */
51 void oc_event_free(oc_event event);
52
53 /**
54  * Waits infinitely for the event to be signaled.
55  *
56  * @param[in]  event  Event to wait on.
57  */
58 void oc_event_wait(oc_event event);
59
60 /**
61  * Waits for the event to be signaled or timed out.
62  *
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.
67  */
68 OCWaitResult_t oc_event_wait_for(oc_event event, uint32_t milliseconds);
69
70 /**
71  * Signals the event.
72  *
73  * @param[in]  event  Event to signal.
74  */
75 void oc_event_signal(oc_event event);
76
77 #ifdef __cplusplus
78 } /* extern "C" */
79 #endif /* __cplusplus */
80
81 #endif /* OC_EVENT_H_ */