|
下面是jaws2的DLL的源代码。
JAWS_Server::open (JAWS_Pipeline_Handler *protocol,
JAWS_Dispatch_Policy *policy)
{
if (policy == 0)
policy = &this->policy_;
JAWS_Data_Block *db = new JAWS_Data_Block;
if (db == 0)
{
ACE_DEBUG ((LM_DEBUG,
"(%t) JAWS_Server::open, could not create Data_Block\n"));
return -1;
}
// initialize data block
db->task (JAWS_Pipeline_Accept_Task_Singleton::instance ());
db->policy (policy);
db->io_handler (0);
db->task ()->next (protocol);
// prime the acceptor if appropriate
if (this->dispatch_ == 1)
{
#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
int n = this->nthreads_;
if (this->concurrency_ == 1)
n = 1;
for (int i = 0; i < n * this->ratio_ - n; i++)
db->task ()->put (db);
#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
}
// The message block should contain an INET_Addr, and call the
// io->accept (INET_Addr) method!
policy->concurrency ()->put (db);
ACE_Thread_Manager::instance ()->wait ();
db->release ();
return 0;
}
下面是main函数的源代码
static JAWS_HTTP_10_Read_Task HTTP_Read;
static JAWS_HTTP_10_Parse_Task HTTP_Parse;
static JAWS_HTTP_10_Write_Task HTTP_Write;
JAWS_Server server (argc, argv);
HTTP_Read.next (&HTTP_Parse);
HTTP_Parse.next (&HTTP_Write);
// HTTP_Write.next (JAWS_Pipeline_Done_Task_Singleton::instance ());
if (server.open (&HTTP_Read) == -1)
ACE_DEBUG ((LM_DEBUG, "JAWS: Error openning server\n"));
JAWS_HTTP_10_***_Task都是继承自JAWS_Pipeline_Handler的。
我有以下几个问题。
1.看到main函数中,server.open 调用之前,使用ACE_Task的next方法把多个JAWS_Pipeline_Handler的派生类,连接到一起。
参考了一些资料,大概可以理解,HTTP_Read.next (&HTTP_Parse);HTTP_Parse.next (&HTTP_Write);
是将我们自定义的处理流程串行保存起来,然后在jaws内部,依次做处理,比如读报文,解析,然后写回去。
内部使用db->task ()->next (protocol);设置进去,然后 db->task ()->put (db);把其设置到JAWS_IO_Handler内部,内部的注释说:
“当io请求完成之后,使用这个task的句柄”。
然后我就没有找到被设置的task如何被JAWS_IO_Handler以及其派生类使用,连接过来之后,
如何开始调用第一个JAWS_HTTP_10_Read_Task HTTP_Read(AWS_Pipeline_Handler的派生类)呢?
[ 本帖最后由 modern 于 2009-3-31 11:00 编辑 ] |
|