-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.hpp
71 lines (44 loc) · 1.24 KB
/
service.hpp
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
/**
*
* @file service
* @brief Copyright (C) 2012 yayanyang All Rights Reserved
* @author yayanyang
* @version 1.0.0.0
* @date 2012/08/29
*/
#ifndef LEMON_TRACE_LOCAL_SERVICE_HPP
#define LEMON_TRACE_LOCAL_SERVICE_HPP
#include <set>
#include <lemon/trace/object.hpp>
#include <lemonxx/memory/ringbuffer.hpp>
namespace lemon{namespace trace{
class Service : public IService
{
public:
typedef std::set<IProvider*> Providers;
typedef std::set<IController*> Controllers;
typedef lemon::memory::ringbuffer::allocator<LEMON_TRACE_MESSAGE_MAX_LENGTH> ringbuffer_type;
Service();
~Service();
private:
void Register(IProvider * object);
void UnRegister(IProvider * object);
void Register(IController * object);
void UnRegister(IController * object);
void OnMessage(const Message * message);
void OnFlagChanged(const LemonUuid * uuid);
private:
void Dispatch();
private:
bool _exit;
Controllers _controllers;
Providers _providers;
lemon::mutex_t _controllerMutex;
lemon::mutex_t _providerMutex;
lemon::mutex_t _mutex;
lemon::condition_variable _cv;
lemon::thread_t _dispatchThread;
ringbuffer_type _ringbuffer;
};
}}
#endif //LEMON_TRACE_LOCAL_SERVICE_HPP