-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.cpp
49 lines (44 loc) · 1012 Bytes
/
main.cpp
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
//
// main.cpp
// Actor1
//
// Created by zhaoAllen on 15/6/14.
// Copyright (c) 2015年 zhaoAllen. All rights reserved.
//
#include <iostream>
#include "threadWrapper.h"
#include <string>
#include "unistd.h"
#include "sys/types.h"
class Log
{
public:
void print_log(Buffer*& pb)
{
std::string str(pb->GetCurData(), pb->GetDataLength());
printf("threadid:%lu %s\n", pthread_self(), str.c_str());
}
};
int main(int argc, const char * argv[]) {
Log log;
printf("maintheadid:%lu\n", pthread_self());
threadWrapper* pa = threadWrapper::createThread(std::bind(&Log::print_log, log, std::placeholders::_1), 10, 1024);
pa->start();
{
Buffer* pb = new Buffer;
std::string test = "test1";
pb->append(test);
pa->send(pb);
}
{
Buffer* pb = new Buffer;
std::string test = "test2";
pb->append(test);
pa->send(pb);
}
pa->stop();
while (true) {
sleep(1);
}
return 0;
}