C++?????????????
???????????? ???????[ 2013/3/25 13:45:10 ] ????????
??????????е???
????????????????з??
??????????????????run????????????е?????????д???????????????????????????????????е?close????????run???????????????????е?close????????????????????е??????????????£?
void close()
{
lock_guard_t lock(m_mutex);
m_flag = false;
m_cond.broadcast();
}
?????????????????????????????????????broadcast?? ??????е?run????????????????????????run?????????????????????????????m_flag ??????????????????????????????????????????????????б??????к?run??????????
??????????????????????е?helloworld???????
class foo_t
{
public:
void print(int data)
{
cout << "helloworld?? data:" <<data << " thread id:"<< ::pthread_self() << endl;
}
void print_callback(int data?? void (*callback_)(int))
{
callback_(data);
}
static void check(int data)
{
cout << "helloworld?? data:" <<data << " thread id:"<< ::pthread_self() << endl;
}
};
// ?????????????
void test_1()
{
thread_t thread;
task_queue_t tq;
thread.create_thread(task_binder_t::gen(&task_queue_t::run?? &tq)?? 1);
foo_t foo;
for (int i = 0; i < 100; ++i)
{
cout << "helloworld?? thread id:"<< ::pthread_self() << endl;
tq.produce(task_binder_t::gen(&foo_t::print?? &foo?? i));
sleep(1);
}
thread.join();
}
int main(int argc?? char* argv[])
{
test_1();
return 0;
}
??????????????????????е??????????????????????????????????????????л???????????????????С????????????????????????????????????á?
????????????????з??
??????????????????????????????????????????????????????а???????????ò??????????в?????п??????
???????漸??????????????
?????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????С?????????????????????????????????????????????????м??ɡ?
?????? ??????????е???socket???д??????????????????????????????????????????????У??????socket??????????????????????????У?????????????????????????????socket?????в??????????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11