ACE studying notes(continuing update....)

本文介绍了ACE框架中的关键组件,包括线程特定存储(TSS)、ACE消息队列、ACE Barrier同步机制等,并探讨了这些组件如何应用于高性能HTTP连接管理和文件传输等功能中。

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 &current_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);
}

先展示下效果 https://pan.quark.cn/s/e81b877737c1 Node.js 是一种基于 Chrome V8 引擎的 JavaScript 执行环境,它使开发者能够在服务器端执行 JavaScript 编程,显著促进了全栈开发的应用普及。 在 Node.js 的开发流程中,`node_modules` 文件夹用于存储所有依赖的模块,随着项目的进展,该文件夹可能会变得异常庞大,其中包含了众多可能已不再需要的文件和文件夹,这不仅会消耗大量的硬盘空间,还可能减慢项目的加载时间。 `ModClean 2.0` 正是为了应对这一挑战而设计的工具。 `ModClean` 是一款用于清理 `node_modules` 的软件,其核心功能是移除那些不再被使用的文件和文件夹,从而确保项目的整洁性和运行效率。 `ModClean 2.0` 是此工具的改进版本,在原有功能上增加了更多特性,从而提高了清理工作的效率和精确度。 在 `ModClean 2.0` 中,用户可以设置清理规则,例如排除特定的模块或文件类型,以防止误删重要文件。 该工具通常会保留项目所依赖的核心模块,但会移除测试、文档、示例代码等非运行时必需的部分。 通过这种方式,`ModClean` 能够协助开发者优化项目结构,减少不必要的依赖,加快项目的构建速度。 使用 `ModClean` 的步骤大致如下:1. 需要先安装 `ModClean`,在项目的根目录中执行以下命令: ``` npm install modclean -g ```2. 创建配置文件 `.modcleanrc.json` 或 `.modcleanrc.js`,设定希望清理的规则。 比如,可能需要忽略 `LICENSE` 文件或整个 `docs`...
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值