How can I know if the php concurrent screenshot capture is complete?
Source: Internet
Author: User
I have a program to capture the picture and package it into a zip file. Currently, a single thread is used because it is too slow. So I want to use multiple threads for concurrent capturing. However, I don't know when to package a zip file. Could you give me some suggestions? & nbsp; how can I know if I have finished capturing php concurrent screenshots?
I have a program to capture the image and package it into a zip file.
Currently, a single thread is used because it is too slow. So I want to use multiple threads for concurrent capturing.
However, I don't know when to package a zip file.
Let's share some suggestions with you:
------ Solution --------------------
Write the disk only after it is captured.
You maintain a target list in the program. when all the objects in the list exist, you can package them.
------ Solution --------------------
PV operation .. You need to maintain a semaphore. It is simply a variable. If you know how many files to capture before running the program, the value is determined at the beginning. for example, if you know that you want to capture 5 images, the value of this variable is 5, when each sub-process completes an image capture action, the variable is reduced by one. when the value is 0, all images are captured.
If you do not know the number of images to capture at the beginning, the semaphore needs to be dynamically maintained, and other semaphores need to be added to control the synchronization between processes. For example, the semaphore may be 0, but there are still processes analyzing whether there are images to capture. because the semaphore is 0, the program exits directly. This situation should also be considered.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service