1TSS(thread-specific storage) (Page240 in APG) could be used in maintaining the connection
state of http connection, or something liked state bean with high performance.
2ACE_Message_Queue (Page204 in APG) is a thread safe data-structure for communication within
process,each thread has its own queue,handler's putq could be used by other threads, and
getq is a blocked function.
3ACE_Barrier (Page 138 in APG) is used for synchonizing a series of threads, it waits for all
threads to come and go.
4"HAStatus" is a fault address in APG, so one should replace this address with real address if he
wants the sample to run.
5ACE time usage:
time_t epoch = ((timespec_t)current_time).tv_sec;
ACE_DEBUG ((LM_INFO,
ACE_TEXT ("handle_timeout: %s"),
ACE_OS::ctime(&epoch)));
6every object or resources are identified by unique handler as pointer to be different from the
same class of objects.
7signal feature seems to be useless on the windows XP platform, the windows system may actually
block the signal.
8The design of the void pointer of arg makes it able to use any kinds of resources, but the
ways and restriction to use it becomes unclear just as the situation of COM.
int handle_timeout (const ACE_Time_Value ¤t_time,
const void *arg)
9ACE file log
ACE_LOG_MSG->msg_ostream (output, 0);
ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM);
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("%IThis will go to STDERR, ")
ACE_TEXT ("syslog & an ostream/n")));
10ACE_Service_Config Class (ACE_HTML/ACE_wrappers/html/ace/classACE__Service__Config.html)
do the config work before calling the real server to serve, for this purpose the server
sould be inherieted as a class of public ACE_Service_Object. This is just a factory pattern.
11JAWS do not work well when multi-thread come from the same client downloading the same file's
different part,it might be the problem of sharing streams.
12JAWS only work for a singal thread whem async working, it shows that proactor use just one thread
within the process to do the job, and let OS to handle else, but in this XP, only two task work
each time.
13because JAWS cache the file before transferring it in the syn pool mode, for this reason,
there are two disadventage. First, if the file is too large too cache, the process break down,
second, the file could not be transfered partially.
14ACE_Asynch_Transmit_File as the detailed desribe is of great use,however it could only in the
Proactor framework ,since it's call back is a ACE_Handler not a ACE_Svc_handler:
This class is a factory for starting off asynchronous transmit files on a stream.
Once <open> is called, multiple asynchronous <transmit_file>s can started using this
class. A ACE_Asynch_Transmit_File::Result will be passed back to the <handler> when the
asynchronous transmit file completes through the <ACE_Handler::handle_transmit_file> callback.
The transmit_file function transmits file data over a connected network connection.
The function uses the operating system's cache manager to retrieve the file data.
This function provides high-performance file data transfer over network connections.
This function would be of great use in a Web Server, Image Server, etc.
ACE_Asynch_Acceptor<ACE_Service_Handler> register itself to Proactor when it is just first open:
virtual int open (const ACE_INET_Addr &address, size_t bytes_to_read=0, int pass_addresses=0, int backlog=ACE_DEFAULT_BACKLOG, int reuse_addr=1, ACE_Proactor *proactor=0, int validate_new_connection=0, int reissue_accept=1, int number_of_initial_accepts=-1)
15ACE_Service_Handler expose its connection with socket through open (ACE_HANDLE h,
ACE_Message_Block&)........ and ACE_Message_Block is used then switch between r/w.
16Look at the codes in JAWS when it implement the syn-pool, it didn't actually has the action
as put the thread into pool when the thread has done its once connection, the thread just
block in the waiting for next connection, it didn't quit:
int
Synch_Thread_Pool_Task::svc (void)
{
// Creates a factory of HTTP_Handlers binding to synchronous I/O strategy
Synch_HTTP_Handler_Factory factory;
for (;;)
{
ACE_SOCK_Stream stream;
// Lock in this accept. When it returns, we have a connection.
if (this->acceptor_.accept (stream) == -1)
ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("%p/n"),
ACE_TEXT ("HTTP_Acceptor::accept")), -1);
ACE_Message_Block *mb;
ACE_NEW_RETURN (mb,
ACE_Message_Block (HTTP_Handler::MAX_REQUEST_SIZE + 1),
-1);
// Create an HTTP Handler to handle this request
HTTP_Handler *handler = factory.create_http_handler ();
handler->open (stream.get_handle (), *mb);
// Handler is destroyed when the I/O puts the Handler into the
// done state.
mb->release ();
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT (" (%t) in Synch_Thread_Pool_Task::svc, recycling/n")));
}
ACE_NOTREACHED(return 0);
}
本文介绍了ACE框架中的关键组件,包括线程特定存储(TSS)、ACE消息队列、ACE Barrier同步机制等,并探讨了这些组件如何应用于高性能HTTP连接管理和文件传输等功能中。
1668

被折叠的 条评论
为什么被折叠?



