找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 3015|回复: 0

使用ACE task 框架时遇到的一个问题

[复制链接]
发表于 2008-8-17 12:17:54 | 显示全部楼层 |阅读模式
我有两个 类,姑且叫 A 类 和 B 类吧

class A: public ACE_Task<..>


{


public:
         int open();


int svc(void);

}; 实现
A::open ()
{
    active();
}
A::svc ()
{
   while(1)
   {
     //这个只是表明意思
      if( EXIT == getq())
      {
          return 0;
      }
   }
   //日志记录
   L_DEBUG("the   A thread svc is exit");
}
class B: public ACE_Task<..>


{


public:
         int open();


int svc(void);
         int send();         int recv();

};

实现:

B::open()

{

    //这里开启两个线程,一个是send线程,专门发送网络数据;一个recv线程,收取网络数据

    active(,2);

}

B::svc()
{
    //开启两个线程
    if(thred[0] == ...)
    {
       send();
    }
    else
    {
       recv();
    }
}
B::int send()
{
    while(1)
    {
      .......
    }
    //记录日志,说明已经退出
    L_DEBUG("the thread send is exit");
}
B::int recv()
{
    while(1)
    {
//使用A类中某个变量将消息放入A的队列
        A::putq()
      .......
    }
    //记录日志,说明已经退出
    L_DEBUG("the thread recvis exit");
}


主函数:


int main()
{
    A a  , B b;
    a.open();
    b.open();
     .............


    a.wait();
    b.wait();
}
程序执行后,创造条件让网络异常,那么a 和 b 都会退出, 可是程序概率性的出现 阻塞,是阻塞在 a.wati()中;


但是从日志中 我却可以明显的看到
("the   A thread svc is exit");
("the thread send is exit");
("the thread recvis exit");
说明 A 类和B类 的线程都已经退出了。 为什么还会阻塞住 呢 ?

如果我将线程属性改为 非  THR_JOINABLE  就不会发生, 为什么?

您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

Archiver|手机版|小黑屋|ACE Developer ( 京ICP备06055248号 )

GMT+8, 2025-4-13 16:25 , Processed in 0.016390 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表