zoukankan      html  css  js  c++  java
  • 关于句柄的一些知识 Handle (computing) Wiki

    原文链接:http://en.wikipedia.org/wiki/Handle_(computing)

    A handle is a particular kind of smart pointer. Handles are used when an application references blocks of memory or objects managed by another system, such as a database or an operating system.

    句柄是一种智能指针。当一个应用程序使用由另一个系统管理的内存时,我们要使用句柄。

    While a pointer literally contains the address of the item to which it refers, a handle is an abstract reference controlled by a separate system; its opacity allows the referent to be relocated in memory by the system without invalidating the handle — impossible with pointers. The extra layer of indirection also increases the control the managing system has over operations performed on the referent (see information hiding, encapsulation).

    一个指针通常包含它引用的对象的地址,而句柄是由一个单独的系统控制的虚拟引用;它可以透明的使引用重新定位到系统分配的内存,而不是使句柄无效,这是指针无法做到的。额外的间接层也增加了管理系统对引用对象实施的操作的控制(参考,信息隐藏,封装)。

    Handles were a popular solution to memory management in operating systems of the 1980s, such as Mac OS and Windows. Unix file descriptors are essentially handles. Like other desktop environments, the Windows API heavily uses handles to represent objects in the system and to provide a communication pathway between the operating system and user space. For example, a window on the desktop is represented by a handle of type HWND.

    句柄是20世纪80年代非常流行的操作系统的内存管理解决方案。,例如Mac OSWindowsUnix的文件说明符在本质上就是句柄。和其他的桌面环境一样,Windows API大量的使用句柄来代表系统中的对象并提供用户空间和操作系统之间的一个交流的通道。例如,桌面中的一个窗口可以被类型为HWND的句柄表示。

    Traditional, doubly-indirect handles have fallen out of favour in recent times, as increases in available memory and improved virtual memory algorithms have made the use of the simpler pointer more attractive. However, many operating systems still apply the term to pointers to opaque, "private" data structures, or indexes into internal arrays passed from one process to its client.

    通常,双指向句柄现在已经不流行了,因为可用内存的增加和改进的虚拟内存算法使得使用简单的指针更具有吸引力。然而,很多操作系统仍然使用不透明的指针,“私有”的数据结构或内部数组的索引来在进程和他的客户之间传递。

  • 相关阅读:
    bzoj1904: Musical Water-fence
    bzoj3822: 文学
    bzoj1513: [POI2006]Tet-Tetris 3D
    bzoj4130: [PA2011]Kangaroos
    bzoj2515 Room
    bzoj2518: [Shoi2010]滚动的正四面体
    bzoj4617: [Wf2016]Spin Doctor
    bzoj3086: Coci2009 dvapravca
    bzoj3745: [Coci2015]Norma
    bzoj1837: [CROATIAN2009]cavli 凸包1
  • 原文地址:https://www.cnblogs.com/oyjj/p/2132991.html
Copyright © 2011-2022 走看看