What does "handle" mean?

Source: Internet
Author: User
The "handle" is used to operate on an "object resource, that is, to operate on a target". what does the "handle" mean? How can I explain how to release a handle? The "handle" is used to operate an "object/resource, that is, to operate a target". what does the "handle" mean? How can I explain how to release a handle?

Reply content:

The "handle" is used to operate an "object/resource, that is, to operate a target". what does the "handle" mean? How can I explain how to release a handle?

Objects are like your objects. The handle is like the mobile phone number of your objects. you don't have to worry about where your objects are at all times. you can call ta whenever necessary, you can call us to say that we broke up.

HandleThe English word ishandle.

The handle is the callback function.

HandleHandle can be interpretedHandle. Use this handle to obtain resources. If you pull your hands, you will be able to hold resources. if you operate on your hands, you will be able to operate on resources. For example:

// Create a resource $ ch = curl_init (); // operate the resource curl_setopt ($ ch, CURLOPT_URL, $ url) according to the handle; curl_setopt ($ ch, CURLOPT_HEADER, TRUE ); curl_setopt ($ ch, CURLOPT_NOBODY, TRUE); // remove bodycurl_setopt ($ ch, CURLOPT_RETURNTRANSFER, TRUE); // execute this resource based on the handle $ head = curl_exec ($ ch );

There is also a word in Englishlove handleIt refers to the small pieces of fat that can be pinched around the belly. the literal translation can be understood as "the handle of Love"

It is similar to a channel, an object that maintains a certain state.
Some resources cannot be directly operated because of their nature, so they need to be operated through the handle.
For example:

  1. Identity is required for database operations. Therefore, after logging on to the database, the handle carries the identity information to operate the database.

  2. The read and write operations of a file have the file pointer position. read and write operations need to control the pointer position. the handle provides a stateful channel.

  3. A timer is a state that assigns a scheduled state to the handle. when something is triggered, you can process the handle (cancel the timer and trigger it in advance.

Your applications usually need to perform operations on objects (data files, custom data structures, etc.), and the handle can be simply understood as a pointer to these objects. after your program is started, these objects are not static in the memory. On the one hand, they are scheduled by the processor, and on the other hand, most operating systems are based on virtual memory space. in this case, the memory manager often moves objects back and forth to meet the needs of the current operation. if we look for objects only by a pointer-pointing to a fixed memory address, obviously, there is no way to deal with the changing actual memory, so the handle can be said to be a pointer to the pointer, although it does not directly point to the object, however, you can use it to learn the changes of the object in the memory, and then indirectly obtain the object

That is to say, the actual address of the object in the memory is usually not fixed, while the fixed handle describes the location of the corresponding object in the memory.

In C, some are pointers to Struct.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.