Queue access method and device
An access method and queue technology, applied in the field of queue access methods and devices, can solve problems such as low efficiency, long thread waiting time, and long time consumption, and achieve the effect of improving efficiency
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0043] When accessing the queue, if multiple threads are used to access the queue by using the locking method, one thread accesses the queue and locks the queue, and if another thread needs to access the queue, since the queue has been locked, At this time, the thread will change from the running state to the waiting state and perform context switching. However, the process of context switching needs to occupy more resources and takes a long time. In addition, if the thread occupying the queue is not unlocked in time, other threads that need to access the queue may wait for a long time. Therefore, the efficiency of queue access by locking is not high.
[0044] In order to improve queue access efficiency, the embodiment of the present invention provides a queue access method, which can be applied to terminals, such terminals include but not limited to mobile phones, computers, tablet computers, etc. limited. see figure 1, the method flow provided by this embodiment includes:...
Embodiment 2
[0067] An embodiment of the present invention provides a method for accessing a queue. Combining the content of the first embodiment above, this embodiment takes the queue access as an operation of enqueueing as an example to illustrate the method provided by this embodiment. see figure 2 , the method flow provided by this embodiment includes:
[0068] 201: Create a second node to be added to the queue, where the second node includes a pointer variable whose value is null;
[0069] The queue contains at least one first node and queue tail pointer variable. The value of the queue tail pointer variable is used to point to the tail node of the queue. The tail node is the first node. Each first node contained in the queue contains at least one pointer variable. The value of the pointer variable is used to point to the next node connected to the current node, and the value of the pointer variable contained in the tail node is empty.
[0070] This embodiment does not specifically...
Embodiment 3
[0087] An embodiment of the present invention provides a method for accessing a queue. Combining with the content of the first embodiment above, the method provided in this embodiment is described with an example. see Figure 4 , the method flow provided by this embodiment includes:
[0088] 401: Obtain the value of the queue head pointer variable;
[0089] The queue contains at least one first node and queue tail pointer variable. The value of the queue tail pointer variable is used to point to the tail node of the queue. The tail node is the first node. Each first node contained in the queue contains at least one pointer variable. The value of the pointer variable is used to point to the next node connected to the current node, and the value of the pointer variable contained in the tail node is empty. In addition, a pseudo-node is included outside the queue, and the pseudo-node includes a pointer variable. The queue also includes a queue head pointer variable, and the valu...
PUM
Login to View More Abstract
Description
Claims
Application Information
Login to View More 


