-
Notifications
You must be signed in to change notification settings - Fork 4
/
ydx_sender.h
49 lines (36 loc) · 924 Bytes
/
ydx_sender.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
#ifndef __YDX_SENDER_H__
#define __YDX_SENDER_H__
#include <boost/scoped_ptr.hpp>
#include <string>
#include "inet_address.h"
#include "ydx_condition.h"
#include "thread.h"
#include "ydx_atomic.h"
#include "callback_types.h"
namespace ydx
{
class EPollPoller;
class StreamBuffer;
class TcpClient;
class Sender
{
public:
Sender(InetAddress& serverAddr,
std::string name = "ydx_sender");
~Sender();
void start();
void onConnection(const TcpConnectionPtr& conn);
void onMessage(const TcpConnectionPtr& conn, Buffer* buf);
//void thread_send_func();
void thread_start_epoll(InetAddress& serverAddr, std::string &name);
bool send(const void* buf, int len);
boost::shared_ptr<EPollPoller> epoller_;
boost::scoped_ptr<StreamBuffer> stream_buffer_;
boost::shared_ptr<TcpClient> client_;
mutable MutexLock mutex_;
Condition cond_;
Thread thread_epoll_;
AtomicInt32 msg_count_;
};
}
#endif