Data transmission method and device based on multiple channels, equipment and storage medium
Patent Information
- Application Number
- CN202111566034.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2041-12-20
AI Technical Summary
[0004]本发明的主要目的在于提出一种基于多通道的数据发送方法、装置、设备及存储介质,旨在解决如何提高数据发送效率,以降低内存占用率的技术问题
[0054] In the multi-channel data transmission method proposed in this invention, when data to be transmitted is detected, a target reading channel is selected from multiple reading channels; the data to be transmitted is added to the target reading channel; the data to be transmitted is read through the reading object corresponding to the target reading channel, and then the data to be transmitted is sent. This solution improves data transmission efficiency and reduces memory usage by setting multiple reading channels and multiple reading objects, adding the data to be transmitted to the target reading channel selected from multiple reading channels, and then reading and sending the data through the corresponding reading object. This avoids rapid queue expansion leading to memory alarms.
Smart Images

Figure CN116361017B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a multi-channel data transmission method, apparatus, device, and storage medium. Background Technology
[0002] In a client / server architecture, the client generates a large amount of information that needs to be uploaded to the server. During the upload process, slow operations such as encrypting and compressing data packets will inevitably block the sending thread. In order to prevent the sending thread from being blocked (blocking may result in the loss of some data), a queue reader / writer design pattern is adopted. However, the consequence of this design is that the data generation rate is much greater than the sending rate, which will cause the queue to expand rapidly and eventually trigger a memory alarm.
[0003] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main objective of this invention is to propose a multi-channel data transmission method, apparatus, device, and storage medium, aiming to solve the technical problem of how to improve data transmission efficiency and reduce memory usage.
[0005] To achieve the above objectives, the present invention provides a multi-channel data transmission method, the multi-channel data transmission method comprising:
[0006] When data to be sent is detected, a target read channel is selected from multiple read channels;
[0007] The data to be sent is added to the target reading channel;
[0008] The data to be sent is read through the reading object corresponding to the target reading channel, and then the data to be sent is sent.
[0009] Optionally, before selecting a target read channel from multiple read channels upon detecting data to be sent, the method further includes:
[0010] Multiple read channels are set up, and a corresponding read object is set up for each read channel. There is a correspondence between the read channels and the read objects. The read objects are used to read data from the corresponding read channels.
[0011] Optionally, selecting a target read channel from multiple read channels when data to be sent is detected includes:
[0012] Upon receiving data to be sent, acquire the data information corresponding to the data to be sent and the channel information corresponding to multiple reading channels;
[0013] The target reading channel is selected from multiple reading channels based on the data information and the channel information.
[0014] Optionally, selecting a target reading channel from multiple reading channels based on the data information and the channel information includes:
[0015] The number of waiting queues in multiple reading channels is determined based on the channel information, and the queue threshold corresponding to each reading channel is obtained.
[0016] The number of waiting queues for each read channel is compared with the queue threshold.
[0017] Based on the comparison results, a candidate read channel is selected from multiple read channels;
[0018] The target reading channel is selected from the candidate reading channels based on the data information and the channel information.
[0019] Optionally, selecting a candidate read channel from multiple read channels based on the comparison result includes:
[0020] Based on the comparison results, select the read channel from multiple read channels whose waiting queue number is less than the queue threshold;
[0021] Read channels with a waiting queue size less than the queue threshold are selected as candidate read channels.
[0022] Optionally, selecting a target reading channel from the candidate reading channels based on the data information and the channel information includes:
[0023] The channel order of the candidate reading channels is determined based on the channel information;
[0024] The target reading channel is selected from the candidate reading channels based on the data information and the channel order.
[0025] Optionally, adding the data to be sent to the target reading channel includes:
[0026] The priority of the data to be sent is determined based on the data information of the data to be sent.
[0027] The data to be sent is added to the target reading channel according to its priority.
[0028] Optionally, adding the data to be sent to the target reading channel according to the priority of the data to be sent includes:
[0029] Obtain the priority of each waiting queue in the target reading channel;
[0030] The data to be sent is added to the target reading channel according to the priority of the data to be sent and the priority of each waiting queue.
[0031] Optionally, adding the data to be sent to the target reading channel according to the priority of the data to be sent and the priority of each waiting queue includes:
[0032] The queue position corresponding to the data to be sent is determined based on the priority of the data to be sent and the priority of each waiting queue;
[0033] The data to be sent is added to the target reading channel according to the queue position.
[0034] Optionally, the step of reading the data to be sent through the reading object corresponding to the target reading channel and sending the data to be sent includes:
[0035] The data in the waiting queue of the target reading channel is read sequentially through the reading object corresponding to the target reading channel;
[0036] When all the data in the waiting queue before the data to be sent has been read, the data to be sent is read through the reading object corresponding to the target reading channel;
[0037] When the data to be sent has been read, the data to be sent is sent.
[0038] Optionally, the step of sequentially reading the data in the waiting queue of the target reading channel through the reading object corresponding to the target reading channel includes:
[0039] The waiting queues in the target reading channel are detected to determine the reading order of each waiting queue;
[0040] According to the reading order, the data in the waiting queue of the target reading channel is read sequentially through the reading object corresponding to the target reading channel.
[0041] Furthermore, to achieve the above objectives, the present invention also proposes a multi-channel data transmission device, the multi-channel data transmission device comprising:
[0042] The channel selection module is used to select the target read channel from multiple read channels when data to be sent is detected;
[0043] A data addition module is used to add the data to be sent to the target reading channel;
[0044] The data sending module is used to read the data to be sent through the reading object corresponding to the target reading channel and send the data to be sent.
[0045] Optionally, the multi-channel data transmission device further includes:
[0046] The channel setting module is used to set up multiple reading channels and set up corresponding reading objects for each reading channel. There is a correspondence between the reading channels and the reading objects, and the reading objects are used to read data from the corresponding reading channels.
[0047] Optionally, the channel selection module is further configured to, upon receiving data to be sent, acquire data information corresponding to the data to be sent and channel information corresponding to multiple reading channels; and select a target reading channel from multiple reading channels based on the data information and the channel information.
[0048] Optionally, the channel selection module is further configured to determine the number of waiting queues in the multiple reading channels based on the channel information, and obtain the queue threshold corresponding to each reading channel; compare the number of waiting queues in each reading channel with the queue threshold; select candidate reading channels from the multiple reading channels based on the comparison results; and select a target reading channel from the candidate reading channels based on the data information and the channel information.
[0049] Optionally, the channel selection module is further configured to select a reading channel from multiple reading channels whose waiting queue number is less than the queue threshold based on the comparison result; and to use the reading channel whose waiting queue number is less than the queue threshold as a candidate reading channel.
[0050] Optionally, the channel selection module is further configured to determine the channel order of the candidate reading channels based on the channel information; and select a target reading channel from the candidate reading channels based on the data information and the channel order.
[0051] Optionally, the data addition module is further configured to determine the priority of the data to be sent based on the data information of the data to be sent; and add the data to be sent to the target reading channel according to the priority of the data to be sent.
[0052] Furthermore, to achieve the above objectives, the present invention also proposes a multi-channel data transmission device, which includes: a memory, a processor, and a multi-channel data transmission program stored in the memory and executable on the processor. When the multi-channel data transmission program is executed by the processor, it implements the multi-channel data transmission method described above.
[0053] Furthermore, to achieve the above objectives, the present invention also proposes a storage medium storing a multi-channel data transmission program, which, when executed by a processor, implements the multi-channel data transmission method as described above.
[0054] In the multi-channel data transmission method proposed in this invention, when data to be transmitted is detected, a target reading channel is selected from multiple reading channels; the data to be transmitted is added to the target reading channel; the data to be transmitted is read through the reading object corresponding to the target reading channel, and then the data to be transmitted is sent. This solution improves data transmission efficiency and reduces memory usage by setting multiple reading channels and multiple reading objects, adding the data to be transmitted to the target reading channel selected from multiple reading channels, and then reading and sending the data through the corresponding reading object. This avoids rapid queue expansion leading to memory alarms. Attached Figure Description
[0055] Figure 1 This is a schematic diagram of the structure of a multi-channel data transmission device in the hardware operating environment involved in the embodiments of the present invention;
[0056] Figure 2 This is a flowchart illustrating the first embodiment of the multi-channel data transmission method of the present invention;
[0057] Figure 3 This is a schematic diagram illustrating the correspondence between the reading channel and the reading object in an embodiment of the multi-channel data transmission method of the present invention;
[0058] Figure 4 This is a flowchart illustrating the second embodiment of the multi-channel data transmission method of the present invention;
[0059] Figure 5 This is a flowchart illustrating the third embodiment of the multi-channel data transmission method of the present invention;
[0060] Figure 6 This is a functional module diagram of the first embodiment of the multi-channel data transmission device of the present invention.
[0061] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0062] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0063] Reference Figure 1 , Figure 1This is a schematic diagram of the structure of a multi-channel data transmission device in the hardware operating environment involved in the embodiments of the present invention.
[0064] like Figure 1 As shown, the multi-channel data transmission device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen and input units such as buttons; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed random access memory (RAM) or non-volatile memory, such as a disk drive. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0065] Those skilled in the art will understand that Figure 1 The device structure shown does not constitute a limitation on multi-channel data transmission devices and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0066] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and a multi-channel data transmission program.
[0067] exist Figure 1 In the multi-channel data transmission device shown, the network interface 1004 is mainly used to connect to the external network and communicate with other network devices; the user interface 1003 is mainly used to connect to the user equipment and communicate with the user equipment; the device of the present invention calls the multi-channel data transmission program stored in the memory 1005 through the processor 1001 and executes the multi-channel data transmission method provided in the embodiment of the present invention.
[0068] Based on the above hardware structure, an embodiment of the multi-channel data transmission method of the present invention is proposed.
[0069] Reference Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the multi-channel data transmission method of the present invention.
[0070] In the first embodiment, the multi-channel data transmission method includes:
[0071] Step S10: When data to be sent is detected, a target reading channel is selected from multiple reading channels.
[0072] It should be noted that the execution subject of this embodiment can be a multi-channel data transmission device, such as a computer device with data processing function, or other devices that can achieve the same or similar functions. This embodiment does not limit this. In this embodiment, a computer device is used as an example for explanation.
[0073] It should be noted that when using the queue-based reader-writer design pattern, the data generation rate is much higher than the transmission rate, which can lead to rapid queue expansion and memory alarms. Due to this drawback, this solution employs multiple readers and multiple read channels. By using multiple readers and multiple read channels, data consumption is accelerated, data transmission efficiency is improved, and memory usage is reduced.
[0074] It should be noted that the data to be sent in this embodiment can be data generated by the client that needs to be sent to the server; that is, the data can be generated by the client and needs to be sent to the server. In addition, the data to be sent can be of different types in different usage scenarios, and this embodiment does not impose any restrictions on this. This embodiment uses data generated by the client that needs to be sent to the server as an example for explanation.
[0075] It should be understood that the reading object in this embodiment is the reader. Multiple reading channels can be set, and a corresponding reading object can be set for each reading channel. There is a correspondence between reading channels and reading objects, and the reading object can be used to read data from the corresponding reading channel. The specific number of reading channels and reading objects can be set according to the actual situation, and this embodiment does not limit this.
[0076] In the specific implementation, you can refer to Figure 3 , Figure 3 This diagram illustrates the correspondence between read channels and read objects. For example, three read channels can be set up: read channel A, read channel B, and read channel C. A corresponding read object A can be set up for read channel A, and data in read channel A can be read through read object A. Similarly, a corresponding read object B can be set up for read channel B, and data in read channel B can be read through read object B. Likewise, a corresponding read object C can be set up for read channel C, and data in read channel C can be read through read object C.
[0077] Understandably, when data to be sent is detected, one of the multiple read channels can be selected as the target read channel, and the data to be sent can be transmitted through the target read channel and the corresponding read object. For example, if the selected target read channel is read channel B, the data to be sent can be transmitted through read channel B and the corresponding read object B; if the selected target read channel is read channel C, the data to be sent can be transmitted through read channel C and the corresponding read object C.
[0078] It should be understood that, in order to avoid an excessive number of waiting queues in the read channel and prevent memory from expanding indefinitely, a queue threshold element can be added to each read channel. If the number of waiting queues in the read channel has reached the queue threshold, then no more data to be sent will be added to that read channel for the time being.
[0079] Step S20: Add the data to be sent to the target reading channel.
[0080] It should be understood that, due to the large amount of information generated by the client, there may already be some data to be sent in the target reading channel selected through the above steps. Therefore, the data to be sent can be added to the target reading channel and placed after the existing waiting queue in the target reading channel, waiting for the reading object corresponding to the target reading channel to read and send the data to be sent.
[0081] It should be understood that since some data may be more urgent than others, priority elements can be added to each data channel to ensure that urgent data can be sent as quickly as possible. This allows setting corresponding priorities for the data and prioritizing it for inclusion in the target read channel. This ensures that higher-priority data is prioritized over lower-priority data, allowing the target read channel to read and send higher-priority data first, followed by lower-priority data.
[0082] Understandably, with the above settings, each read object has its own read channel, and each read object can prioritize reading data with higher priority. Furthermore, to prevent excessive data volume, a queue threshold can be added to prevent unlimited memory expansion. This solution significantly improves data transmission efficiency, reduces memory usage, ensures that system memory is not exhausted even with excessively large data volumes, and effectively solves the problem of business disruptions caused by the failure to send critical data in a timely manner.
[0083] Step S30: Read the data to be sent through the reading object corresponding to the target reading channel, and send the data to be sent.
[0084] Understandably, through the design of this solution, the reading objects can read and send data in their respective reading channels. Therefore, the data to be sent can be read by the reading object corresponding to the target reading channel, and the data to be sent can be sent out.
[0085] It should be understood that, due to the queuing situation, the reading object cannot directly read the data to be sent. Instead, the data in the waiting queue of the target reading channel can be read sequentially through the reading object corresponding to the target reading channel. When all the data in the waiting queue in front of the data to be sent has been read, the data to be sent can be read through the reading object corresponding to the target reading channel. And when the data to be sent has been read, the data to be sent can be sent.
[0086] Understandably, the waiting queues in the target read channel can be detected to determine the reading order of each waiting queue, and then the data in the waiting queues in the target read channel can be read sequentially according to the reading order through the corresponding read object of the target read channel.
[0087] In a practical implementation, for example, suppose the target read channel is read channel B. Read channel B has two waiting queues preceding the data to be sent: waiting queue A and waiting queue B. After detection, it can be determined that the reading order of the waiting queues is to read waiting queue A first, then waiting queue B. Therefore, according to the reading order, waiting queues A and B in read channel B can be read sequentially through read object B. After both waiting queues A and B preceding the data to be sent have been read, the data to be sent can be read through read object B, and the data to be sent can be sent upon completion of the reading process.
[0088] Understandably, this solution employs multiple read channels and multiple read objects, and adds priority elements and queue threshold elements to each read channel. Data to be sent can be added to one of the multiple read channels in sequence. Then, the data consumption is accelerated by using multiple read objects. Furthermore, by setting priorities, some urgent data can be promptly notified to the server, allowing the server to obtain the current status of the client in a timely manner.
[0089] In this embodiment, upon detecting data to be sent, a target reading channel is selected from multiple reading channels; the data to be sent is added to the target reading channel; the data to be sent is read through the reading object corresponding to the target reading channel, and then sent. This solution improves data transmission efficiency and reduces memory usage by setting multiple reading channels and multiple reading objects. It adds the data to be sent to the selected target reading channel and then reads and sends the data through the corresponding reading object. This avoids rapid queue expansion that could lead to memory alarms.
[0090] In one embodiment, such as Figure 4 As shown, based on the first embodiment, a second embodiment of the multi-channel data transmission method of the present invention is proposed. Step S10 includes:
[0091] Step S101: When receiving data to be sent, obtain the data information corresponding to the data to be sent and the channel information corresponding to multiple reading channels.
[0092] It should be understood that when receiving data to be sent, the data information corresponding to the data to be sent, as well as the channel information currently corresponding to multiple reading channels, can be obtained simultaneously. Then, the target reading channel can be selected by combining the data information and the channel information.
[0093] It is understood that channel information may include the number of waiting queues in the waiting queue of the reading channel, the channel order of reading the channel, and data information may include the amount of data. In addition, channel information and data information may include other information, which is not limited in this embodiment.
[0094] Step S102: Select a target reading channel from multiple reading channels based on the data information and the channel information.
[0095] Understandably, in order to improve the efficiency of data reading and data sending, data information and channel information can be combined to select a suitable reading channel from multiple reading channels as the target reading channel.
[0096] Furthermore, to avoid an excessive number of waiting queues in the read channel and to prevent unlimited memory expansion that could lead to computer malfunction, step S102 includes:
[0097] The number of waiting queues in multiple reading channels is determined based on the channel information, and the queue threshold corresponding to each reading channel is obtained; the number of waiting queues in each reading channel is compared with the queue threshold; a candidate reading channel is selected from multiple reading channels based on the comparison result; and a target reading channel is selected from the candidate reading channels based on the data information and the channel information.
[0098] It should be understood that after obtaining the channel information, the number of waiting queues in multiple read channels can be determined based on the channel information. Then, the queue threshold corresponding to each read channel is obtained. Based on the number of waiting queues in each read channel and the corresponding queue threshold, it is determined whether the read channel has reached its load. If the read channel has reached its load, it is filtered out, and no data to be sent is considered to be added to that read channel. If the read channel has not reached its load, it is designated as a candidate read channel, and then the target read channel is selected from the candidate read channels based on the data information and channel information.
[0099] It is understandable that the number of waiting queues for each read channel can be compared with the queue threshold to obtain multiple comparison results. If the comparison result is that the number of waiting queues is less than the queue threshold, it means that the read channel has not reached its load. If the comparison result is that the number of waiting queues is greater than or equal to the queue threshold, it means that the read channel has reached its load. In this embodiment, the read channels with a number of waiting queues less than the queue threshold (i.e., the read channels that have not reached their load) are selected as candidate read channels.
[0100] Understandably, after determining the candidate read channels, the channel order can be determined based on the channel information. This channel order can be pre-set, allowing data to be added sequentially to one of the multiple read channels. Furthermore, the amount of data to be sent can be considered when selecting a read channel, thus improving read efficiency. Therefore, the amount of data to be sent can be determined based on the data information, and then the target read channel can be selected from the candidate read channels based on the data volume and channel order, adding the data to be sent to the target read channel.
[0101] In a practical implementation, for example, suppose the queue threshold set for read channel A is threshold A, the queue threshold set for read channel B is threshold B, and the queue threshold set for read channel C is threshold C. If the number of waiting queues corresponding to read channel A is quantity A, the number of waiting queues corresponding to read channel B is quantity B, and the number of waiting queues corresponding to read channel C is quantity C, then quantity A can be compared with threshold A, quantity B can be compared with threshold B, and quantity C can be compared with threshold C. If the comparison result is that quantity A is greater than or equal to threshold A, quantity B is less than threshold B, and quantity C is less than threshold C, then read channels B and C can be selected as candidate read channels. If the channel order is that read channel B is listed before read channel C, then read channel B can be selected as the target read channel from the candidate read channels.
[0102] In this embodiment, when receiving data to be sent, the data information corresponding to the data to be sent and the channel information corresponding to multiple reading channels are obtained. Based on the data information and the channel information, a target reading channel is selected from multiple reading channels. This allows for the accurate selection of a suitable reading channel as the target reading channel for reading and sending the data to be sent, further improving the processing efficiency of data reading and sending.
[0103] In one embodiment, such as Figure 5 As shown, a third embodiment of the multi-channel data transmission method of the present invention is proposed based on the first or second embodiment. In this embodiment, the description is based on the first embodiment. Step S20 includes:
[0104] Step S201: Determine the priority of the data to be sent based on the data information of the data to be sent.
[0105] It should be understood that since some data may be more urgent than others, priority elements can be added to each data channel to ensure that urgent data can be sent as quickly as possible. This allows setting corresponding priorities for the data and prioritizing it for inclusion in the target read channel. This ensures that higher-priority data is prioritized over lower-priority data, allowing the target read channel to read and send higher-priority data first, followed by lower-priority data.
[0106] Therefore, in order to determine the urgency of the data to be sent, the priority of the data to be sent can be determined based on the data information of the data to be sent. The priority of the data to be sent can be set when inputting the data, or the priority can be set for different data types first, and then the data type to which the data to be sent belongs can be determined, and the priority corresponding to the data type can be used as the priority of the data to be sent. In addition, the priority of the data to be sent can be determined by other methods, and this embodiment does not limit this.
[0107] Step S202: Add the data to be sent to the target reading channel according to the priority of the data to be sent.
[0108] It should be understood that, since there may be situations where the data to be sent is more urgent than the data in the waiting queue in the reading channel, in order to take a more comprehensive approach, in addition to considering the priority of the data to be sent, the priority of each waiting queue in the target reading channel can also be considered. The priority of the data to be sent and the priority of each waiting queue are combined to determine the queue position corresponding to the data to be sent, and then the data to be sent is added to the target reading channel according to the queue position.
[0109] In specific implementations, for example, if the priority of the data to be sent is higher than the priority of all waiting queues in the target read channel, then the data to be sent is added to the front of the waiting queues in the target read channel, so that the read object processes the data to be sent first. If the priority of the data to be sent is lower than or equal to the priority of all waiting queues in the target read channel, then the data to be sent is added to the back of the waiting queues in the target read channel, so that the read object processes the data in the target read channel sequentially according to the queue order. If the priority of the data to be sent is higher than some waiting queues but lower than some waiting queues, then the data to be sent is added between the high-priority waiting queues and the low-priority waiting queues, so that the read object processes the high-priority waiting queues first, then processes the data to be sent, and finally processes the low-priority waiting queues.
[0110] In this embodiment, the priority of the data to be sent is determined based on the data information of the data to be sent, and the data to be sent is added to the target reading channel according to the priority of the data to be sent. Thus, by setting the priority, each reading object can read the data with higher priority in the corresponding reading channel first, and some urgent data can be notified to the server in a timely manner, so that the server can get the current status of the client in a timely manner.
[0111] Furthermore, this embodiment of the invention also proposes a storage medium storing a multi-channel data transmission program, which, when executed by a processor, implements the steps of the multi-channel data transmission method described above.
[0112] Since this storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought about by the technical solutions of the above embodiments, which will not be repeated here.
[0113] In addition, refer to Figure 6 The present invention also proposes a multi-channel data transmission device, the multi-channel data transmission device comprising:
[0114] The channel selection module 10 is used to select a target reading channel from multiple reading channels when data to be sent is detected.
[0115] It should be noted that when using the queue-based reader-writer design pattern, the data generation rate is much higher than the transmission rate, which can lead to rapid queue expansion and memory alarms. Due to this drawback, this solution employs multiple readers and multiple read channels. By using multiple readers and multiple read channels, data consumption is accelerated, data transmission efficiency is improved, and memory usage is reduced.
[0116] It should be noted that the data to be sent in this embodiment can be data generated by the client that needs to be sent to the server; that is, the data can be generated by the client and needs to be sent to the server. In addition, the data to be sent can be of different types in different usage scenarios, and this embodiment does not impose any restrictions on this. This embodiment uses data generated by the client that needs to be sent to the server as an example for explanation.
[0117] It should be understood that the reading object in this embodiment is the reader. Multiple reading channels can be set, and a corresponding reading object can be set for each reading channel. There is a correspondence between reading channels and reading objects, and the reading object can be used to read data from the corresponding reading channel. The specific number of reading channels and reading objects can be set according to the actual situation, and this embodiment does not limit this.
[0118] In the specific implementation, you can refer to Figure 3 , Figure 3 This diagram illustrates the correspondence between read channels and read objects. For example, three read channels can be set up: read channel A, read channel B, and read channel C. A corresponding read object A can be set up for read channel A, and data in read channel A can be read through read object A. Similarly, a corresponding read object B can be set up for read channel B, and data in read channel B can be read through read object B. Likewise, a corresponding read object C can be set up for read channel C, and data in read channel C can be read through read object C.
[0119] Understandably, when data to be sent is detected, one of the multiple read channels can be selected as the target read channel, and the data to be sent can be transmitted through the target read channel and the corresponding read object. For example, if the selected target read channel is read channel B, the data to be sent can be transmitted through read channel B and the corresponding read object B; if the selected target read channel is read channel C, the data to be sent can be transmitted through read channel C and the corresponding read object C.
[0120] It should be understood that, in order to avoid an excessive number of waiting queues in the read channel and prevent memory from expanding indefinitely, a queue threshold element can be added to each read channel. If the number of waiting queues in the read channel has reached the queue threshold, then no more data to be sent will be added to that read channel for the time being.
[0121] The data addition module 20 is used to add the data to be sent to the target reading channel.
[0122] It should be understood that, due to the large amount of information generated by the client, there may already be some data to be sent in the target reading channel selected through the above steps. Therefore, the data to be sent can be added to the target reading channel and placed after the existing waiting queue in the target reading channel, waiting for the reading object corresponding to the target reading channel to read and send the data to be sent.
[0123] It should be understood that since some data may be more urgent than others, priority elements can be added to each data channel to ensure that urgent data can be sent as quickly as possible. This allows setting corresponding priorities for the data and prioritizing it for inclusion in the target read channel. This ensures that higher-priority data is prioritized over lower-priority data, allowing the target read channel to read and send higher-priority data first, followed by lower-priority data.
[0124] Understandably, with the above settings, each read object has its own read channel, and each read object can prioritize reading data with higher priority. Furthermore, to prevent excessive data volume, a queue threshold can be added to prevent unlimited memory expansion. This solution significantly improves data transmission efficiency, reduces memory usage, ensures that system memory is not exhausted even with excessively large data volumes, and effectively solves the problem of business disruptions caused by the failure to send critical data in a timely manner.
[0125] The data sending module 30 is used to read the data to be sent through the reading object corresponding to the target reading channel and send the data to be sent.
[0126] Understandably, through the design of this solution, the reading objects can read and send data in their respective reading channels. Therefore, the data to be sent can be read by the reading object corresponding to the target reading channel, and the data to be sent can be sent out.
[0127] It should be understood that, due to the queuing situation, the reading object cannot directly read the data to be sent. Instead, the data in the waiting queue of the target reading channel can be read sequentially through the reading object corresponding to the target reading channel. When all the data in the waiting queue in front of the data to be sent has been read, the data to be sent can be read through the reading object corresponding to the target reading channel. And when the data to be sent has been read, the data to be sent can be sent.
[0128] Understandably, the waiting queues in the target read channel can be detected to determine the reading order of each waiting queue, and then the data in the waiting queues in the target read channel can be read sequentially according to the reading order through the corresponding read object of the target read channel.
[0129] In a practical implementation, for example, suppose the target read channel is read channel B. Read channel B has two waiting queues preceding the data to be sent: waiting queue A and waiting queue B. After detection, it can be determined that the reading order of the waiting queues is to read waiting queue A first, then waiting queue B. Therefore, according to the reading order, waiting queues A and B in read channel B can be read sequentially through read object B. After both waiting queues A and B preceding the data to be sent have been read, the data to be sent can be read through read object B, and the data to be sent can be sent upon completion of the reading process.
[0130] Understandably, this solution employs multiple read channels and multiple read objects, and adds priority elements and queue threshold elements to each read channel. Data to be sent can be added to one of the multiple read channels in sequence. Then, the data consumption is accelerated by using multiple read objects. Furthermore, by setting priorities, some urgent data can be promptly notified to the server, allowing the server to obtain the current status of the client in a timely manner.
[0131] In this embodiment, upon detecting data to be sent, a target reading channel is selected from multiple reading channels; the data to be sent is added to the target reading channel; the data to be sent is read through the reading object corresponding to the target reading channel, and then sent. This solution improves data transmission efficiency and reduces memory usage by setting multiple reading channels and multiple reading objects. It adds the data to be sent to the selected target reading channel and then reads and sends the data through the corresponding reading object. This avoids rapid queue expansion that could lead to memory alarms.
[0132] In one embodiment, the multi-channel data transmission device further includes a channel setting module for setting multiple reading channels and setting a corresponding reading object for each reading channel. There is a correspondence between the reading channel and the reading object, and the reading object is used to read data from the corresponding reading channel.
[0133] In one embodiment, the channel selection module 10 is further configured to, upon receiving data to be sent, acquire data information corresponding to the data to be sent and channel information corresponding to multiple reading channels; and select a target reading channel from multiple reading channels based on the data information and the channel information.
[0134] In one embodiment, the channel selection module 10 is further configured to determine the number of waiting queues in the multiple reading channels according to the channel information, and obtain the queue threshold corresponding to each reading channel; compare the number of waiting queues in each reading channel with the queue threshold; select candidate reading channels from the multiple reading channels according to the comparison result; and select a target reading channel from the candidate reading channels according to the data information and the channel information.
[0135] In one embodiment, the channel selection module 10 is further configured to select a reading channel from multiple reading channels whose waiting queue number is less than a queue threshold based on the comparison result; and to use the reading channel whose waiting queue number is less than the queue threshold as a candidate reading channel.
[0136] In one embodiment, the channel selection module 10 is further configured to determine the channel order of the candidate reading channels based on the channel information; and select a target reading channel from the candidate reading channels based on the data information and the channel order.
[0137] In one embodiment, the data addition module 20 is further configured to determine the priority of the data to be sent based on the data information of the data to be sent; and add the data to be sent to the target reading channel according to the priority of the data to be sent.
[0138] In one embodiment, the data addition module 20 is further configured to obtain the priority of each waiting queue in the target reading channel; and add the data to be sent to the target reading channel according to the priority of the data to be sent and the priority of each waiting queue.
[0139] In one embodiment, the data addition module 20 is further configured to determine the queue position corresponding to the data to be sent based on the priority of the data to be sent and the priority of each waiting queue; and add the data to be sent to the target reading channel according to the queue position.
[0140] In one embodiment, the data sending module 30 is further configured to sequentially read the data in the waiting queue of the target reading channel through the reading object corresponding to the target reading channel; when all the data in the waiting queue before the data to be sent has been read, read the data to be sent through the reading object corresponding to the target reading channel; and send the data to be sent when the data to be sent has been read.
[0141] In one embodiment, the data sending module 30 is further configured to detect the waiting queues in the target reading channel to determine the reading order of each waiting queue; and to read the data in the waiting queues in the target reading channel sequentially through the reading object corresponding to the target reading channel according to the reading order.
[0142] Other embodiments or specific implementation methods of the multi-channel data transmission device described in this invention can be referred to the above-described method embodiments, and will not be repeated here.
[0143] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0144] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0145] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This estimation machine software product is stored in an estimation machine readable storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a smart device (which may be a mobile phone, an estimation machine, a multi-channel data transmission device, or a network multi-channel data transmission device, etc.) to execute the methods described in the various embodiments of the present invention.
[0146] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A multi-channel data transmission method, characterized in that, The multi-channel-based data transmission method includes: When data to be sent is detected, a target reading channel is selected from multiple reading channels, and a queue threshold is added to each reading channel. If the number of waiting queues in a reading channel reaches the queue threshold, no data to be sent is added to that reading channel. The data to be sent is added to the target reading channel; The data to be sent is read through the reading object corresponding to the target reading channel, and then the data to be sent is sent.
2. The data transmission method based on multiple channels as described in claim 1, characterized in that, Before selecting a target read channel from multiple read channels when data to be sent is detected, the method further includes: Multiple read channels are set up, and a corresponding read object is set up for each read channel. There is a correspondence between the read channels and the read objects. The read objects are used to read data from the corresponding read channels.
3. The data transmission method based on multiple channels as described in claim 1, characterized in that, The step of selecting a target read channel from multiple read channels when data to be sent is detected includes: Upon receiving data to be sent, acquire the data information corresponding to the data to be sent and the channel information corresponding to multiple reading channels; The target reading channel is selected from multiple reading channels based on the data information and the channel information.
4. The data transmission method based on multiple channels as described in claim 3, characterized in that, The step of selecting a target reading channel from multiple reading channels based on the data information and the channel information includes: The number of waiting queues in multiple reading channels is determined based on the channel information, and the queue threshold corresponding to each reading channel is obtained. The number of waiting queues for each read channel is compared with the queue threshold. Based on the comparison results, a candidate read channel is selected from multiple read channels; The target reading channel is selected from the candidate reading channels based on the data information and the channel information.
5. The data transmission method based on multiple channels as described in claim 4, characterized in that, The step of selecting a candidate read channel from multiple read channels based on the comparison results includes: Based on the comparison results, select the read channel from multiple read channels whose waiting queue number is less than the queue threshold; Read channels with a waiting queue size less than the queue threshold are selected as candidate read channels.
6. The data transmission method based on multiple channels as described in claim 4, characterized in that, The step of selecting a target reading channel from the candidate reading channels based on the data information and the channel information includes: The channel order of the candidate reading channels is determined based on the channel information; The target reading channel is selected from the candidate reading channels based on the data information and the channel order.
7. The data transmission method based on multiple channels as described in any one of claims 1 to 6, characterized in that, Adding the data to be sent to the target reading channel includes: The priority of the data to be sent is determined based on the data information of the data to be sent. The data to be sent is added to the target reading channel according to its priority.
8. The data transmission method based on multiple channels as described in claim 7, characterized in that, The step of adding the data to be sent to the target reading channel according to the priority of the data to be sent includes: Obtain the priority of each waiting queue in the target reading channel; The data to be sent is added to the target reading channel according to the priority of the data to be sent and the priority of each waiting queue.
9. The data transmission method based on multiple channels as described in claim 8, characterized in that, The step of adding the data to be sent to the target reading channel according to the priority of the data to be sent and the priority of each waiting queue includes: The queue position corresponding to the data to be sent is determined based on the priority of the data to be sent and the priority of each waiting queue; The data to be sent is added to the target reading channel according to the queue position.
10. The data transmission method based on multiple channels as described in any one of claims 1 to 6, characterized in that, The step of reading the data to be sent through the reading object corresponding to the target reading channel and sending the data to be sent includes: The data in the waiting queue of the target reading channel is read sequentially through the reading object corresponding to the target reading channel; When all the data in the waiting queue before the data to be sent has been read, the data to be sent is read through the reading object corresponding to the target reading channel; When the data to be sent is read, the data to be sent is sent.
11. The data transmission method based on multiple channels as described in claim 10, characterized in that, The step of sequentially reading data from the waiting queue in the target reading channel through the reading object corresponding to the target reading channel includes: The waiting queues in the target reading channel are detected to determine the reading order of each waiting queue; According to the reading order, the data in the waiting queue of the target reading channel is read sequentially through the reading object corresponding to the target reading channel.
12. A multi-channel data transmission device, characterized in that, The multi-channel data transmission device includes: The channel selection module is used to select a target reading channel from multiple reading channels when data to be sent is detected, and add a queue threshold to each reading channel. If the number of waiting queues in a reading channel reaches the queue threshold, no data to be sent is added to that reading channel. The data addition module is used to add the data to be sent to the target reading channel; The data sending module is used to read the data to be sent through the reading object corresponding to the target reading channel and send the data to be sent.
13. The multi-channel data transmission device as described in claim 12, characterized in that, The multi-channel data transmission device further includes: The channel setting module is used to set up multiple reading channels and set up corresponding reading objects for each reading channel. There is a correspondence between the reading channels and the reading objects, and the reading objects are used to read data from the corresponding reading channels.
14. The multi-channel data transmission device as described in claim 12, characterized in that, The channel selection module is further configured to, upon receiving data to be sent, acquire data information corresponding to the data to be sent and channel information corresponding to multiple reading channels; and select a target reading channel from multiple reading channels based on the data information and the channel information.
15. The multi-channel data transmission device as described in claim 14, characterized in that, The channel selection module is also used to determine the number of waiting queues in the waiting queues of multiple reading channels based on the channel information, and to obtain the queue threshold corresponding to each reading channel. The number of waiting queues for each read channel is compared with the queue threshold. Based on the comparison results, a candidate read channel is selected from multiple read channels; The target reading channel is selected from the candidate reading channels based on the data information and the channel information.
16. The multi-channel data transmission device as described in claim 15, characterized in that, The channel selection module is further configured to select a reading channel from multiple reading channels whose waiting queue number is less than the queue threshold based on the comparison result; and to use the reading channel whose waiting queue number is less than the queue threshold as the candidate reading channel.
17. The multi-channel data transmission device as described in claim 15, characterized in that, The channel selection module is further configured to determine the channel order of the candidate reading channels based on the channel information; and select a target reading channel from the candidate reading channels based on the data information and the channel order.
18. The multi-channel data transmission device as described in claim 12, characterized in that, The data addition module is further configured to determine the priority of the data to be sent based on the data information of the data to be sent; and to add the data to be sent to the target reading channel according to the priority of the data to be sent.
19. A multi-channel data transmission device, characterized in that, The multi-channel data transmission device includes: a memory, a processor, and a multi-channel data transmission program stored in the memory and executable on the processor. When the multi-channel data transmission program is executed by the processor, it implements the multi-channel data transmission method as described in any one of claims 1 to 11.
20. A storage medium, characterized in that, The storage medium stores a multi-channel data transmission program, which, when executed by a processor, implements the multi-channel data transmission method as described in any one of claims 1 to 11.
Citation Information
Patent Citations
Multi-thread data lock-free processing method and device and electronic equipment
CN113051057A