简体   繁体   English

如何在共享内存段中创建apr_table_t类型的表?

[英]How can I create an apr_table_t type's table in shared memory segment?

如何在共享内存段中创建apr_table_t类型的表?

There is no way to create that except of writing your own implementation. 除了编写自己的实现之外,没有其他方法可以创建它。 Note that you must predefine the maximum amount of memory that your hash table will take since APR doesn't support a shared memory segments resizing. 请注意,由于APR不支持调整共享内存段的大小,因此您必须预先定义哈希表将占用的最大内存量。 However you can use APR DBM library to create a thread-safe file database based on a hash table, it's pretty fast and easy to use. 但是,您可以使用APR DBM库基于哈希表创建线程安全的文件数据库,它非常快速且易于使用。

This may not be possible unless shared memory is mapped to the same virtual address. 除非共享内存映射到相同的虚拟地址,否则这可能是不可能的。

Documentation for the apr_shm_baseaddr_get function says: apr_shm_baseaddr_get函数的文档说:

Retrieve the base address of the shared memory segment. 检索共享内存段的基地址。 NOTE: This address is only usable within the callers address space, since this API does not guarantee that other attaching processes will maintain the same address mapping. 注意:此地址仅在调用者地址空间内可用,因为此API不保证其他附加进程将维护相同的地址映射。

APR apr_shm_baseaddr_get documentation APR apr_shm_baseaddr_get文档

Internally the apr_table_t struct is using apr_array_header_t which contains pointers to apr_pool_t and char (array elements). 内部apr_table_t结构使用apr_array_header_t,其中包含指向apr_pool_t和char(数组元素)的指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM