Revision: 386 Author: yongjun.mao Date: Wed Mar 3 22:00:34 2010 Log: interprocess译至6% http://code.google.com/p/boost-doc-zh/source/detail?r=386 Modified: /trunk/libs/interprocess/doc/interprocess.qbk ======================================= --- /trunk/libs/interprocess/doc/interprocess.qbk Mon Feb 1 04:53:06 2010 +++ /trunk/libs/interprocess/doc/interprocess.qbk Wed Mar 3 22:00:34 2010 @@ -400,50 +400,38 @@ [endsect] -[section:emulation Emulation for systems without shared memory objects] - -[*Boost.Interprocess] provides portable shared memory in terms of POSIX -semantics. Some operating systems don't support shared memory as defined by -POSIX: --* Windows operating systems provide shared memory using memory backed by the
- paging file but the lifetime semantics are different from the ones- defined by POSIX (see [link interprocess.sharedmemorybetweenprocesses.sharedmemory.windows_shared_memory
- Native windows shared memory] section for more information). --* Some UNIX systems don't fully support POSIX shared memory objects at all.
- -In those platforms, shared memory is emulated with mapped files created -in a "boost_interprocess" folder created in a temporary files directory. -In Windows platforms, if "Common AppData" key is present -in the registry, "boost_interprocess" folder is created in that directory -(in XP usually "C:\Documents and Settings\All Users\Application Data" and -in Vista "C:\ProgramData").-For Windows platforms without that registry key and Unix systems, shared memory is
-created in the system temporary files directory ("/tmp" or similar). - -Because of this emulation, shared memory has filesystem lifetime in some -of those systems. +[section:emulation 无共享内存对象的系统下的模拟支持] ++[*Boost.Interprocess] 提供了POSIX语义下的可移植共享内存。一些操作系统并不支 持POSIX规格的共享内存:
+ +* Windows系统利用分页文件实现共享内存,但它的生命期与任一POSIX规格不同+(请参阅[link interprocess.sharedmemorybetweenprocesses.sharedmemory.windows_shared_memory
+ 原生Windows共享内存]段)。 + +* 一些UNIX系统并非完全支持POSIX共享内在对象。 ++在这些平台中,使用创建于临时目录里的"boost_interprocess"文件夹下的映射文件 来模拟共享内存。 +在Windows平台中,如果注册表中有"Common AppData"键,"boost_interprocess"文件 夹创建在其指定的目录中 +(XP系统一般是"C:\Documents and Settings\All Users\Application Data",Vista系统则是"C:\ProgramData")。 +至于没有该注册表键的Windows平台或Unix系统,共享内存创建于系统临时文件目录下 (类似于"/tmp")。
+ +因此,在上述的系统中,共享内存的生命期为文件生命周期。 [endsect] -[section:removing Removing shared memory] +[section:removing 移除共享内存] [classref boost::interprocess::shared_memory_object shared_memory_object] -provides a static `remove` function to remove a shared memory objects. - -This function [*can] fail if the shared memory objects does not exist or -it's opened by another process. Note that this function is similar to the -standard C `int remove(const char *path)` function. In UNIX systems, -`shared_memory_object::remove` calls `shm_unlink`: - -* The function will remove the name of the shared memory object -named by the string pointed to by name. - -* If one or more references to the shared memory object exist when -is unlinked, the name will be removed before the function returns, but the -removal of the memory object contents will be postponed until all open and -map references to the shared memory object have been removed. +有一个静态的`remove`函数来移除一个共享内存对象。 + +如果共享内存对象不存在或正被其它进程打开着,这个函数[*会]失败。+这个函数有点类似于标准C函数中的`int remove(const char *path)`。在UNIX系统 里,
+`shared_memory_object::remove`调用`shm_unlink`: + +* 该函数将移除由字符串指针指定的共享内存对象的名称。 + +* 如果存在一个或多个共享内存对象的引用,函数返回前名称将被移除, +但内存对象的内容会推迟到所有打开该共享内存对象和映射引用全部移除时才移除。* Even if the object continues to exist after the last function call, reuse of
the name will subsequently cause the creation of a