CN111240834A - Task execution method and device, electronic equipment and storage medium - Google Patents

Task execution method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111240834A
CN111240834A CN202010003212.0A CN202010003212A CN111240834A CN 111240834 A CN111240834 A CN 111240834A CN 202010003212 A CN202010003212 A CN 202010003212A CN 111240834 A CN111240834 A CN 111240834A
Authority
CN
China
Prior art keywords
tasks
executed
blocking
task
queue
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010003212.0A
Other languages
Chinese (zh)
Other versions
CN111240834B (en
Inventor
李明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010003212.0A priority Critical patent/CN111240834B/en
Publication of CN111240834A publication Critical patent/CN111240834A/en
Application granted granted Critical
Publication of CN111240834B publication Critical patent/CN111240834B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the disclosure discloses a task execution method, a task execution device, an electronic device and a storage medium, wherein the method comprises the following steps: acquiring a task to be executed; and if the preset blocking queue is determined not to meet the blocking condition, adding the tasks to be executed into the blocking queue so as to execute the tasks to be executed in the blocking queue in parallel based on a set waiting group, wherein the set waiting group is used for realizing the execution of batch tasks. According to the technical scheme, through the setting of the blocking queue, parallel processing of a plurality of tasks can be achieved in the GO-language-based equipment based on the set waiting group, batch and parallel processing of batch tasks are further achieved, the defect that the performance of the equipment is poor due to the fact that the quantity of the parallel-processed tasks is too large is avoided, and task execution efficiency is improved.

Description

Task execution method and device, electronic equipment and storage medium
Technical Field
The embodiment of the disclosure relates to the technical field of computers, and in particular, to a task execution method and apparatus, an electronic device, and a storage medium.
Background
With the development of intelligent terminals, in order to meet the efficient requirements of users on task processing, many tasks in a service platform or equipment can be processed in parallel.
Often during batch processing of tasks, it is often desirable to limit the number of concurrent tasks. For example, when data is queried in batches, a large number of connections to the database at the same time are not desired, a batch of tasks is processed after being completed, and then the next batch of tasks is processed, and each batch of tasks can be specified with a concurrency number. However, in the GO language, since how many tasks are received in the concurrent processing procedure for the tasks in the GO language, that is, the corresponding coroutine (Goroutine) is called for concurrent processing, the number of the tasks to be concurrently processed is not limited. Although coroutines in the GO language are called by depending on a user layer, the coroutines do not provide the authority for controlling the life cycle of the coroutines, so that research and development personnel cannot control the quantity of tasks to be processed concurrently, and when the quantity of the tasks to be processed concurrently is large, the running of equipment can be influenced.
Disclosure of Invention
The embodiment of the disclosure provides a task execution method and device, electronic equipment and a storage medium, so that in GO-language-based equipment, batch processing of parallel tasks is realized, and the efficiency of task execution is improved.
In a first aspect, an embodiment of the present disclosure provides a task execution method, including:
acquiring a task to be executed;
and if the preset blocking queue is determined not to meet the blocking condition, adding the to-be-executed tasks into the blocking queue so as to execute the to-be-executed tasks in the blocking queue in parallel based on a set waiting group, wherein the set waiting group is used for realizing the execution of batch tasks.
In a second aspect, an embodiment of the present disclosure further provides a task execution device, including:
the task acquisition module is used for acquiring a task to be executed;
and the task execution module is used for adding the to-be-executed tasks into the blocking queue if the preset blocking queue is determined not to meet the blocking condition, so as to execute the to-be-executed tasks in the blocking queue in parallel based on a set waiting group, wherein the set waiting group is used for realizing the execution of batch tasks.
In a third aspect, an embodiment of the present disclosure further provides an electronic device, where the electronic device includes:
one or more processors;
storage means for storing one or more programs;
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the task execution method as described above.
In a fourth aspect, the disclosed embodiments also provide a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the task execution method described above.
According to the method and the device for executing the tasks, the tasks to be executed are obtained, if the preset blocking queue is determined not to meet the blocking condition, the tasks to be executed are added into the blocking queue, the tasks to be executed in the blocking queue are executed in parallel based on the set waiting group, and the set waiting group is used for executing the tasks in batches. According to the technical scheme, through the setting of the blocking queue, parallel processing of a plurality of tasks can be achieved in the GO-language-based equipment based on the set waiting group, batch and parallel processing of batch tasks are further achieved, the defect that the performance of the equipment is poor due to the fact that the quantity of the parallel-processed tasks is too large is avoided, and task execution efficiency is improved.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale.
FIG. 1 is a flow chart of a method of task execution in an embodiment of the present disclosure;
FIG. 2 is a flow diagram of another method of task execution in an embodiment of the present disclosure;
FIG. 3 is a schematic structural diagram of a task execution device according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an electronic device in an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
Fig. 1 is a flowchart of a task execution method in an embodiment of the present disclosure, where the embodiment is applicable to a case of executing a task in a GO language-based device, and the method may be executed by a task execution apparatus, where the apparatus may be implemented in a software and/or hardware manner, and the apparatus may be configured in an electronic device, such as a server or a terminal device, where a typical terminal device includes a mobile terminal, and specifically includes a mobile phone, a computer, or a tablet computer. As shown in fig. 1, the method may specifically include:
and S110, acquiring a task to be executed.
The tasks to be executed are tasks which are generated in the GO-language-based device and need to be executed, the number and types of the tasks to be executed are not limited in the scheme, and the tasks to be executed generated in the device can be generated in batches.
Specifically, the task execution device may obtain the task to be executed in the device based on a preset task obtaining program or algorithm.
And S120, if the preset blocking queue is determined not to meet the blocking condition, adding the to-be-executed tasks into the blocking queue so as to execute the to-be-executed tasks in the blocking queue in parallel based on the set waiting group.
The blocking queue is a queue which is preset in the equipment and used for storing the tasks to be executed. The waiting Group is set to be a waiting Group (Wait Group) for realizing the execution of batch tasks in the device, the waiting Group is a task execution mechanism in the GO language, the waiting Group can block the execution of the main thread, and the next Group of tasks is executed continuously after the coroutine execution corresponding to the current Group of tasks is finished. Coroutine (Goroutine) is a lightweight abstraction established on threads, multiple coroutines can be executed under one thread, and resources occupied by each coroutine and switching overhead are small compared with the threads.
Specifically, determining that the preset blocking queue does not satisfy the blocking condition may include: determining the task number of tasks to be executed in a blocking queue; and if the determined task number is less than the concurrent task number, determining that the blocking queue does not meet the blocking condition. After the to-be-executed tasks are acquired, the task number of the to-be-executed tasks currently included in the blocking queue can be counted, and if the task number is smaller than the concurrent task number, the blocking queue does not meet the blocking condition and is not blocked. The number of concurrent tasks refers to the maximum allowable number of tasks set by the blocking queue, and the specific number of concurrent tasks may be set according to an actual situation, for example, the number of concurrent tasks may be 10.
Further, adding the to-be-executed tasks to the blocking queue to execute the to-be-executed tasks in the blocking queue in parallel based on the set waiting group may include: adding the tasks to be executed into a blocking queue, and adding the tasks to be executed in the blocking queue into a set waiting group when the blocking queue meets a blocking condition; and calling corresponding coroutines in parallel, and executing the tasks to be executed in the blocking queue.
The blocking condition may be that the number of the tasks to be executed in the blocking queue is equal to the number of the concurrent tasks, and therefore when the number of the tasks to be executed in the blocking queue is equal to the number of the concurrent tasks, it may be determined that the blocking queue satisfies the blocking condition, at this time, the tasks to be executed in the blocking queue may be added to the set waiting group at one time, and the coroutines corresponding to the tasks to be executed are called in parallel to execute each of the executed tasks. After the task to be executed is executed based on the set waiting group, the task to be executed in the blocking queue can be deleted, and the addition of a new task to be executed is waited.
The number of the allowed-to-call coroutines set by the set waiting group may be the same as the number of the concurrent tasks in the blocking queue, or the number of the allowed-to-call coroutines may be greater than the number of the concurrent tasks. In addition, the number of allowed schedules and the number of concurrent tasks in the blocking queue set by the set waiting group may be set according to time, the number of tasks or device performance parameters, and may also be set according to real-time requirements. For example, the number of concurrent tasks may be reset at intervals of a set time, or the number of concurrent tasks may be reset at intervals of a set task number, or the set time and the set task number may also be set according to an actual situation, which is not limited in this scheme. The flexible adjustment of the number of the concurrent tasks can enable each batch of tasks to be assigned with different concurrent numbers, and the flexibility is improved.
According to the method and the device for executing the tasks, the tasks to be executed are obtained, if the preset blocking queue is determined not to meet the blocking condition, the tasks to be executed are added into the blocking queue, the tasks to be executed in the blocking queue are executed in parallel based on the set waiting group, and the set waiting group is used for executing the tasks in batches. According to the technical scheme, through the setting of the blocking queue, the parallel processing of batch tasks can be realized in the GO-language-based equipment based on the set waiting group, so that the batching and parallel processing of a plurality of tasks are realized, the defect of poor performance of the equipment caused by the overlarge task amount of the parallel processing is avoided, and the task execution efficiency is improved.
Fig. 2 is a flowchart of another task execution method in an embodiment of the present disclosure. On the basis of the above embodiments, the present embodiment further optimizes the task execution method. Correspondingly, as shown in fig. 2, the method of the embodiment specifically includes:
and S210, acquiring a task to be executed.
And S220, determining whether the preset blocking queue meets the blocking condition.
The blocking condition may be that the number of the to-be-executed tasks in the blocking queue is equal to the number of the concurrent tasks.
Specifically, the task number of the tasks to be executed in the blocking queue is determined, the task number is compared with the preset concurrent task number, and whether the blocking condition is met is determined. If the number of the tasks is less than the number of the concurrent tasks, it is determined that the blocking condition is not satisfied, and S230 is executed, and if the number of the tasks is equal to the number of the concurrent tasks, it is determined that the blocking condition is satisfied, and S240 is executed.
And S230, adding the tasks to be executed into the blocking queue so as to execute the tasks to be executed in the blocking queue in parallel based on the set waiting group.
Wherein the waiting group is set for implementing the execution of the batch task.
Specifically, if the blocking queue does not meet the blocking condition, adding the task to be executed to the blocking queue, so as to add the task to be executed in the blocking queue to the set waiting group when waiting for the blocking queue to meet the blocking condition; and calling corresponding coroutines in parallel, and executing the tasks to be executed in the blocking queue. Wherein, the number of allowed calls and the number of concurrent tasks of the blocking queue set by the waiting group can be the same. And setting the number of the allowed programs to be called and the number of the concurrent tasks of the blocking queue according to time, the number of the tasks or equipment performance parameters.
S240, blocking the blocking queue, and executing the tasks to be executed in the blocking queue in parallel based on the set waiting group.
And if the blocking queue meets the blocking condition, blocking the blocking queue, namely the currently acquired task to be executed cannot be added into the blocking queue. After blocking the blocking queue, the tasks to be executed in the blocking queue can be executed in parallel based on the set waiting group.
And S250, unblocking the blocking queue, emptying the task to be executed, and adding a new task to be executed into the blocking queue.
And after the parallel processing of the tasks to be executed in the blocking queue is completed, the blocking queue is unblocked, and the processed tasks to be executed are emptied. At this time, if a new task to be executed is obtained, the task to be executed may be added to the blocking queue, and when the blocking queue meets the blocking condition again, a new batch of tasks to be executed is executed in parallel.
According to the scheme, through the setting of the blocking queue and the setting of the waiting group, on the basis of batch processing of tasks, parallel processing can be performed, and then a plurality of acquired tasks can be processed in batches and in parallel, so that on the basis of avoiding unsmooth running of equipment due to excessive parallel tasks, the task processing performance is improved.
The method comprises the steps of obtaining tasks to be executed, determining whether a preset blocking queue meets a blocking condition, if the preset blocking queue does not meet the blocking condition, adding the tasks to be executed into the blocking queue, and executing the tasks to be executed in the blocking queue in parallel based on a set waiting group; and if the blocking queue meets the blocking condition, blocking the blocking queue, executing the tasks to be executed in the blocking queue in parallel based on the set waiting group, unblocking the blocking queue, emptying the tasks to be executed, and adding a new task to be executed to the blocking queue. According to the technical scheme, through the setting of the blocking queue, parallel processing of a plurality of tasks can be achieved in the GO-language-based equipment based on the set waiting group, batch and parallel processing of batch tasks are further achieved, the defect that the performance of the equipment is poor due to the fact that the quantity of the parallel-processed tasks is too large is avoided, and task execution efficiency is improved.
Fig. 3 is a schematic structural diagram of a task execution device in the embodiment of the present disclosure, which is applicable to a case of executing a task in a GO language-based device. The task execution device provided by the embodiment of the disclosure can execute the task execution method provided by any embodiment of the disclosure, and has corresponding functional modules and beneficial effects of the execution method.
The device specifically includes a task obtaining module 310 and a task executing module 320, where:
a task obtaining module 310, configured to obtain a task to be executed;
the task execution module 320 is configured to add the to-be-executed task to the blocking queue if it is determined that the preset blocking queue does not satisfy the blocking condition, so as to execute the to-be-executed task in the blocking queue in parallel based on a set waiting group, where the set waiting group is used to implement execution of batch tasks.
Optionally, the task execution module 320 includes a blocking determination unit, and the blocking determination unit is specifically configured to:
determining the task number of tasks to be executed in the blocking queue;
and if the determined task quantity is less than the concurrent task quantity, determining that the blocking queue does not meet the blocking condition.
Optionally, the task execution module 320 includes a task adding unit, and the task adding unit is specifically configured to:
adding the to-be-executed tasks into the blocking queue to wait for the to-be-executed tasks in the blocking queue to be added into the set waiting group when the blocking queue meets the blocking condition;
and calling corresponding coroutines in parallel, and executing the tasks to be executed in the blocking queue.
Optionally, the number of allowed dispatches set by the set waiting group is the same as the number of concurrent tasks in the blocking queue.
Optionally, the number of coroutines allowed to be called and the number of concurrent tasks of the blocking queue set by the set waiting group are set according to time, the number of tasks, or device performance parameters.
Optionally, the apparatus further comprises:
and the blocking module is used for blocking the blocking queue and executing the tasks to be executed in the blocking queue in parallel based on a set waiting group if the blocking queue meets the blocking condition after the tasks to be executed are obtained.
Optionally, the blocking module is further configured to:
and blocking the blocking queue, removing the blocking of the blocking queue and emptying the task to be executed after the task to be executed in the blocking queue is executed in parallel based on a set waiting group, and adding a new task to be executed to the blocking queue.
The task execution device provided by the embodiment of the disclosure can execute the task execution method provided by any embodiment of the disclosure, and has corresponding functional modules and beneficial effects of the execution method.
Fig. 4 is a schematic structural diagram of an electronic device in an embodiment of the present disclosure. Referring now specifically to fig. 4, a schematic diagram of an electronic device 400 suitable for use in implementing embodiments of the present disclosure is shown. The electronic device 400 in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle-mounted terminal (e.g., a car navigation terminal), and the like, and fixed terminals such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 4, electronic device 400 may include a processing device (e.g., central processing unit, graphics processor, etc.) 401 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage device 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the electronic apparatus 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
Generally, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 408 including, for example, tape, hard disk, etc.; and a communication device 409. The communication means 409 may allow the electronic device 400 to communicate wirelessly or by wire with other devices to exchange data. While fig. 4 illustrates an electronic device 400 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device 409, or from the storage device 408, or from the ROM 402. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 401.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText transfer protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring a task to be executed; and if the preset blocking queue is determined not to meet the blocking condition, adding the to-be-executed tasks into the blocking queue so as to execute the to-be-executed tasks in the blocking queue in parallel based on a set waiting group, wherein the set waiting group is used for realizing the execution of batch tasks.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of an element does not in some cases constitute a limitation on the element itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, there is provided a task execution method including:
acquiring a task to be executed;
and if the preset blocking queue is determined not to meet the blocking condition, adding the to-be-executed tasks into the blocking queue so as to execute the to-be-executed tasks in the blocking queue in parallel based on a set waiting group, wherein the set waiting group is used for realizing the execution of batch tasks.
According to one or more embodiments of the present disclosure, in a task execution method provided by the present disclosure, the determining that a preset blocking queue does not satisfy a blocking condition includes:
determining the task number of tasks to be executed in the blocking queue;
and if the determined task quantity is less than the concurrent task quantity, determining that the blocking queue does not meet the blocking condition.
According to one or more embodiments of the present disclosure, in a task execution method provided by the present disclosure, adding the to-be-executed task to the blocking queue to execute the to-be-executed task in the blocking queue in parallel based on a set waiting group includes:
adding the to-be-executed tasks into the blocking queue to wait for the to-be-executed tasks in the blocking queue to be added into the set waiting group when the blocking queue meets the blocking condition;
and calling corresponding coroutines in parallel, and executing the tasks to be executed in the blocking queue.
According to one or more embodiments of the present disclosure, in the task execution method provided by the present disclosure, the number of coroutines allowed to be called set by the setting waiting group is the same as the number of concurrent tasks in the blocking queue.
According to one or more embodiments of the present disclosure, in the task execution method provided by the present disclosure, the number of coroutines allowed to be called and the number of concurrent tasks of the blocking queue, which are set by the set waiting group, are set according to time, the number of tasks, or a device performance parameter.
According to one or more embodiments of the present disclosure, in the task execution method provided by the present disclosure, after acquiring the task to be executed, the method further includes:
and if the blocking queue is determined to meet the blocking condition, blocking the blocking queue, and executing the tasks to be executed in the blocking queue in parallel based on a set waiting group.
According to one or more embodiments of the present disclosure, in the task execution method provided by the present disclosure, after blocking the blocking queue and executing the to-be-executed tasks in the blocking queue in parallel based on the set waiting group, the method further includes:
and unblocking the blocking queue, emptying the task to be executed, and adding a new task to be executed into the blocking queue.
According to one or more embodiments of the present disclosure, there is provided a task performing apparatus including:
the task acquisition module is used for acquiring a task to be executed;
and the task execution module is used for adding the to-be-executed tasks into the blocking queue if the preset blocking queue is determined not to meet the blocking condition, so as to execute the to-be-executed tasks in the blocking queue in parallel based on a set waiting group, wherein the set waiting group is used for realizing the execution of batch tasks.
According to one or more embodiments of the present disclosure, in the task execution device provided by the present disclosure, the task execution module includes a blocking determination unit, where the blocking determination unit is specifically configured to:
determining the task number of tasks to be executed in the blocking queue;
and if the determined task quantity is less than the concurrent task quantity, determining that the blocking queue does not meet the blocking condition.
According to one or more embodiments of the present disclosure, in the task execution device provided by the present disclosure, the task execution module includes a task adding unit, and the task adding unit is specifically configured to:
adding the to-be-executed tasks into the blocking queue to wait for the to-be-executed tasks in the blocking queue to be added into the set waiting group when the blocking queue meets the blocking condition;
and calling corresponding coroutines in parallel, and executing the tasks to be executed in the blocking queue.
According to one or more embodiments of the present disclosure, in the task execution device provided by the present disclosure, the number of coroutines allowed to be called set by the set waiting group is the same as the number of concurrent tasks of the blocking queue.
According to one or more embodiments of the present disclosure, in the task execution device provided by the present disclosure, the number of coroutines allowed to be called and the number of concurrent tasks of the blocking queue, which are set by the setting waiting group, are set according to time, the number of tasks, or a device performance parameter.
According to one or more embodiments of the present disclosure, in a task execution device provided by the present disclosure, the device further includes:
and the blocking module is used for blocking the blocking queue and executing the tasks to be executed in the blocking queue in parallel based on a set waiting group if the blocking queue meets the blocking condition after the tasks to be executed are obtained.
According to one or more embodiments of the present disclosure, in the task execution device provided by the present disclosure, the blocking module is further configured to: and blocking the blocking queue, removing the blocking of the blocking queue and emptying the task to be executed after the task to be executed in the blocking queue is executed in parallel based on a set waiting group, and adding a new task to be executed to the blocking queue.
In accordance with one or more embodiments of the present disclosure, there is provided an electronic device including:
one or more processors;
a memory for storing one or more programs;
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement any of the task execution methods provided by the present disclosure.
According to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a task execution method as any one of the task execution methods provided by the present disclosure.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (10)

1. A method of task execution, comprising:
acquiring a task to be executed;
and if the preset blocking queue is determined not to meet the blocking condition, adding the to-be-executed tasks into the blocking queue so as to execute the to-be-executed tasks in the blocking queue in parallel based on a set waiting group, wherein the set waiting group is used for realizing the execution of batch tasks.
2. The method of claim 1, wherein the determining that the predetermined congestion queue does not satisfy the congestion condition comprises:
determining the task number of tasks to be executed in the blocking queue;
and if the determined task quantity is less than the concurrent task quantity, determining that the blocking queue does not meet the blocking condition.
3. The method of claim 1, wherein adding the to-be-executed task to the blocked queue for parallel execution of the to-be-executed task in the blocked queue based on a set wait group comprises:
adding the to-be-executed tasks into the blocking queue to wait for the to-be-executed tasks in the blocking queue to be added into the set waiting group when the blocking queue meets the blocking condition;
and calling corresponding coroutines in parallel, and executing the tasks to be executed in the blocking queue.
4. The method of claim 3, wherein the number of allowed dispatches for the set waiting group setting is the same as the number of concurrent tasks for the blocked queue.
5. The method of claim 3, wherein the number of allowed dispatches and the number of concurrent tasks of the blocking queue set by the set waiting group are set according to time, number of tasks, or device performance parameters.
6. The method of claim 1, wherein after obtaining the task to be performed, further comprising:
and if the blocking queue is determined to meet the blocking condition, blocking the blocking queue, and executing the tasks to be executed in the blocking queue in parallel based on a set waiting group.
7. The method of claim 6, wherein after blocking the blocked queue and executing the tasks to be executed in the blocked queue in parallel based on the set wait group, further comprising:
and unblocking the blocking queue, emptying the task to be executed, and adding a new task to be executed into the blocking queue.
8. A task execution apparatus, comprising:
the task acquisition module is used for acquiring a task to be executed;
and the task execution module is used for adding the to-be-executed tasks into the blocking queue if the preset blocking queue is determined not to meet the blocking condition, so as to execute the to-be-executed tasks in the blocking queue in parallel based on a set waiting group, wherein the set waiting group is used for realizing the execution of batch tasks.
9. An electronic device, characterized in that the electronic device comprises:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a task execution method as recited in any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method for performing a task according to any one of claims 1 to 7.
CN202010003212.0A 2020-01-02 2020-01-02 Task execution method, device, electronic equipment and storage medium Active CN111240834B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010003212.0A CN111240834B (en) 2020-01-02 2020-01-02 Task execution method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010003212.0A CN111240834B (en) 2020-01-02 2020-01-02 Task execution method, device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111240834A true CN111240834A (en) 2020-06-05
CN111240834B CN111240834B (en) 2024-02-02

Family

ID=70866419

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010003212.0A Active CN111240834B (en) 2020-01-02 2020-01-02 Task execution method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111240834B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113626171A (en) * 2021-08-26 2021-11-09 北京京东乾石科技有限公司 Method, device and system for analyzing task execution efficiency of warehousing execution equipment
CN113778650A (en) * 2021-09-14 2021-12-10 北京沃东天骏信息技术有限公司 Task scheduling method and device, electronic equipment and storage medium
CN115086371A (en) * 2022-06-07 2022-09-20 苏州奈特力智能科技有限公司 NVR data transmission method based on 5G and ten-gigabit network communication technology
CN115134254A (en) * 2022-06-28 2022-09-30 抖音视界(北京)有限公司 Network simulation method, device, equipment and storage medium
CN115601195A (en) * 2022-10-17 2023-01-13 桂林电子科技大学(Cn) Transaction bidirectional recommendation system and method based on real-time label of power user

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030135621A1 (en) * 2001-12-07 2003-07-17 Emmanuel Romagnoli Scheduling system method and apparatus for a cluster
CN102365624A (en) * 2009-04-08 2012-02-29 飞思卡尔半导体公司 Debug signaling in a multiple processor data processing system
US20160299791A1 (en) * 2014-01-14 2016-10-13 Tencent Technology (Shenzhen) Company Limited Method And Apparatus For Processing Computational Task
US20180203724A1 (en) * 2017-01-17 2018-07-19 International Business Machines Corporation Fast task dispatching using a dispatching processor
CN110543359A (en) * 2019-07-03 2019-12-06 威富通科技有限公司 Task queue running device
WO2019237593A1 (en) * 2018-06-13 2019-12-19 平安科技(深圳)有限公司 Task processing method and apparatus, and computer device and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030135621A1 (en) * 2001-12-07 2003-07-17 Emmanuel Romagnoli Scheduling system method and apparatus for a cluster
CN102365624A (en) * 2009-04-08 2012-02-29 飞思卡尔半导体公司 Debug signaling in a multiple processor data processing system
US20160299791A1 (en) * 2014-01-14 2016-10-13 Tencent Technology (Shenzhen) Company Limited Method And Apparatus For Processing Computational Task
US20180203724A1 (en) * 2017-01-17 2018-07-19 International Business Machines Corporation Fast task dispatching using a dispatching processor
WO2019237593A1 (en) * 2018-06-13 2019-12-19 平安科技(深圳)有限公司 Task processing method and apparatus, and computer device and storage medium
CN110543359A (en) * 2019-07-03 2019-12-06 威富通科技有限公司 Task queue running device

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113626171A (en) * 2021-08-26 2021-11-09 北京京东乾石科技有限公司 Method, device and system for analyzing task execution efficiency of warehousing execution equipment
CN113626171B (en) * 2021-08-26 2024-04-05 北京京东乾石科技有限公司 Method, device and system for analyzing task execution efficiency of warehouse execution equipment
CN113778650A (en) * 2021-09-14 2021-12-10 北京沃东天骏信息技术有限公司 Task scheduling method and device, electronic equipment and storage medium
CN115086371A (en) * 2022-06-07 2022-09-20 苏州奈特力智能科技有限公司 NVR data transmission method based on 5G and ten-gigabit network communication technology
CN115134254A (en) * 2022-06-28 2022-09-30 抖音视界(北京)有限公司 Network simulation method, device, equipment and storage medium
CN115134254B (en) * 2022-06-28 2023-11-03 抖音视界(北京)有限公司 Network simulation method, device, equipment and storage medium
CN115601195A (en) * 2022-10-17 2023-01-13 桂林电子科技大学(Cn) Transaction bidirectional recommendation system and method based on real-time label of power user
CN115601195B (en) * 2022-10-17 2023-09-08 桂林电子科技大学 Transaction bidirectional recommendation system and method based on real-time label of power user

Also Published As

Publication number Publication date
CN111240834B (en) 2024-02-02

Similar Documents

Publication Publication Date Title
CN111240834B (en) Task execution method, device, electronic equipment and storage medium
CN111950988B (en) Distributed workflow scheduling method and device, storage medium and electronic equipment
CN113722056A (en) Task scheduling method and device, electronic equipment and computer readable medium
CN110430142B (en) Method and device for controlling flow
CN112379982B (en) Task processing method, device, electronic equipment and computer readable storage medium
CN110795446A (en) List updating method and device, readable medium and electronic equipment
CN113760991A (en) Data operation method and device, electronic equipment and computer readable medium
CN110768861B (en) Method, device, medium and electronic equipment for obtaining overtime threshold
CN115357350A (en) Task configuration method and device, electronic equipment and computer readable medium
CN112418389A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN110489219B (en) Method, device, medium and electronic equipment for scheduling functional objects
CN113886212A (en) User state control method and device, electronic equipment and storage medium
CN111694670B (en) Resource allocation method, apparatus, device and computer readable medium
CN116821187A (en) Database-based data processing method and device, medium and electronic equipment
CN111324387A (en) Application task control method, device, terminal and system
CN111898061A (en) Method, device, electronic equipment and computer readable medium for searching network
CN111209042B (en) Method, device, medium and electronic equipment for establishing function stack
CN113518183A (en) Camera calling method and device and electronic equipment
CN112148448A (en) Resource allocation method, device, equipment and computer readable medium
CN113176937A (en) Task processing method and device and electronic equipment
CN111756833A (en) Node processing method and device, electronic equipment and computer readable medium
CN111538717A (en) Data processing method and device, electronic equipment and computer readable medium
CN111538577A (en) Program execution control device and method, terminal and storage medium
CN111459893B (en) File processing method and device and electronic equipment
CN111258670B (en) Method and device for managing component data, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant