| | |
| | | |
| | | void* con = createConsumer(t, c); |
| | | |
| | | char ip[] = "192.168.20.108:4150"; |
| | | GoString addr = {ip, (ptrdiff_t)strlen(ip)}; |
| | | |
| | | // thread |
| | | thread([&con,&addr]{ |
| | | Run(con, addr); |
| | | thread([&con]{ |
| | | |
| | | // char ip[] = "192.168.20.108:4150"; |
| | | // GoString addr = {ip, (ptrdiff_t)strlen(ip)}; |
| | | // Run(con, addr); |
| | | |
| | | char lip[] = "192.168.20.108:4161"; |
| | | GoString laddr = {lip, (ptrdiff_t)strlen(lip)}; |
| | | RunLookupd(con, laddr); |
| | | |
| | | }).detach(); |
| | | |
| | | auto start = chrono::steady_clock::now(); |
| | |
| | | printf("======>> recv msg %s size %d\n", (char*)msg, count); |
| | | relMessage(msg); |
| | | if (count > 999000){ |
| | | printf("======>> use time %d\n", |
| | | printf("======>> use time %ld\n", |
| | | chrono::duration_cast<chrono::seconds>(chrono::steady_clock::now()-start).count()); |
| | | } |
| | | } |
| | |
| | | |
| | | int main(int argc, char const *argv[]) |
| | | { |
| | | thread([]{ |
| | | produce(true); |
| | | bool two = false; |
| | | |
| | | thread([two]{ |
| | | produce(two); |
| | | }).detach(); |
| | | |
| | | thread([]{ consume("test2", "sensor01"); }).detach(); |
| | | if (two) thread([]{ consume("test2", "sensor01"); }).detach(); |
| | | |
| | | consume("test", "sensor01"); |
| | | |
| | |
| | | } |
| | | return nil |
| | | }) |
| | | |
| | | // go c.Run("192.168.20.108:4150", 2) |
| | | go c.RunLookupd("192.168.20.108:4161", 2) |
| | | |
| | |
| | | } |
| | | |
| | | func Test() { |
| | | go produce(true) |
| | | two := false |
| | | go produce(two) |
| | | |
| | | go consume("test2", "sensor01") |
| | | if two { |
| | | go consume("test2", "sensor01") |
| | | } |
| | | consume("test", "sensor01") |
| | | } |