forked from ARMmbed/mbed-events
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventLoop.h
74 lines (63 loc) · 2.25 KB
/
EventLoop.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* events
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef MBED_CONF_RTOS_PRESENT
#ifndef EVENT_LOOP_H
#define EVENT_LOOP_H
#include "EventQueue.h"
#include "Thread.h"
namespace events {
/** EventLoop
*
* An event queue wrapped in a thread
*/
class EventLoop : public EventQueue {
public:
/** Create an event loop
*
* @param priority Initial priority of the thread
* (default: osPriorityNormal)
* @param queue_size Size of buffer to use for events
* (default: DEFAULT_QUEUE_SIZE)
* @param queue_pointer Pointer to memory region to use for events
* (default: NULL)
* @param stack_size Stack size (in bytes) requirements for the thread
* (default: DEFAULT_STACK_SIZE)
* @param stack_pointer Pointer to stack area to be used by the thread
* (default: NULL)
*/
EventLoop(osPriority priority=osPriorityNormal,
unsigned event_size=DEFAULT_QUEUE_SIZE,
unsigned char *event_pointer=NULL,
uint32_t stack_size=DEFAULT_STACK_SIZE,
unsigned char *stack_pointer=NULL);
/** Clean up event loop
*/
~EventLoop();
/** Starts an event loop running in a dedicated thread
* @return status code that indicates the execution status of the function.
*/
osStatus start();
/** Stops an event loop cleanly, waiting for any currently executing events
* @return status code that indicates the execution status of the function.
*/
osStatus stop();
private:
rtos::Thread _thread;
bool _running;
};
}
#endif
#endif