-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCoChannel.h
More file actions
52 lines (30 loc) · 734 Bytes
/
CoChannel.h
File metadata and controls
52 lines (30 loc) · 734 Bytes
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
#ifndef __COCHANNEL_H__
#define __COCHANNEL_H__
#include <stdio.h>
class Coroutine;
class CoEventLoop;
class CoChannel
{
public:
static CoChannel* create(const std::string& name = "default_name");
void send(void* data);
void close();
bool recv();
void* get_data();
std::string name();
private:
CoChannel(const std::string& name);
//the receiver auto release this
~CoChannel();
struct ChannelData
{
bool is_ok_;
void* data_;
};
void* recv_data_;
ChannelData* chann_data_;
bool first_call_recv_;
std::string name_;
friend class Coroutine;
};
#endif