dialog box[HUD Showanimated:yes whileexecutingblock:^{What to do when the dialog box is displayedSleep (3);} completionblock:^{Actions that are performed after the operation is complete, suppress the dialog box[HUD Removefromsuperview];HUD = nil; Change object values in block, __block}];}Progress Tip Box One-(Ibaction) PROGRESSDIALOG1: (ID) Sender {Create a Progress box__block Mbprogresshud *hud = [[Mbprogresshud Alloc]initwithview:self.view];[Self.view Addsubview:hud];Hud.labeltext = @ "Loadin
the experiment simple, only a simple regular expression matching is performed on the processing of the returned results, without other complicated operations. in addition, to determine the impact of result processing callback on performance comparison test results, you can use usleep to simulate the data processing logic (such as extraction, word segmentation, writing files or databases) that is more appropriate in reality ).The callback functions us
The locks we have seen are similar to defining a variable true first. after the related operation is completed, the related value is changed to false. {code ...} the locks we have seen are similar to defining a variable = true first. after the related operation is completed, the related value is changed to false.
$ Lock_num = 0; while (! Redis_helper: lock ("lottery") {if ($ lock_num> = 300) {return "Dear, many people are waiting in queue to grab red packets. please go to the page again ";} //
simple regular expression matching is performed on the processing of the returned results, without other complicated operations. in addition, to determine the impact of result processing callback on performance comparison test results, you can use usleep to simulate the data processing logic (such as extraction, word segmentation, writing files or databases) that is more appropriate in reality ).The callback functions used in performance testing are:
performance comparison test results, you can use usleep to simulate the data processing logic (such as extraction, word segmentation, writing files or databases) that is more appropriate in reality ).
The callback functions used in performance testing are:
The code is as follows:
Function callback ($ data, $ delay ){Preg_match_all ('/(. +) Usleep ($ delay );Return compact ('data', 'matches ');}
When d
test results, you can use usleep to simulate the data processing logic (such as extraction, word segmentation, writing files or databases) that is more appropriate in reality ).
The callback functions used in performance testing are:
The code is as follows:
Function callback ($ data, $ delay ){Preg_match_all ('/(. +) Usleep ($ delay );Return compact ('data', 'matches ');}
When data processing callback
ntsysv command, you can see all the services of the system and whether they are started together with the system. here, you can customize system services. The operation interface is shown in, here we can see that the test program autoruntest has been added as a system service and runs along with the system. Here you can customize the started service. press F1 to see the introduction of each service. The system service description is attached.
3 Appendix
3.1 Service script file example
#! /Bin
PHP regularly runs the following code. a test.txt file can be generated under the current folder, and a timestamp can be written to it every 20 seconds, regardless of whether the client closes the browser.
Ignore_user_abort (true );
Set_time_limit (0 );
Function write_txt (){If (! File_exists(”test.txt ")){$ Fp = fopen(‑test.txt "," wb ");Fclose ($ fp );}$ Str = file_get_contents('test.txt ');$ Str. = "\ r \ n". date ("H: I: s ");$ Fp = fopen(‑test.txt "," wb ");Fwrite ($ fp, $ str );Fclo
Go online Check, first is the Sleep series (sleep/usleep/nanosleep/time_sleep_until) function, first of these functions have a problem, sleep is the current process hangs, such as:
echo time();sleep(10);echo time();
In fact, " wait for 10 seconds ", " again " Display two timestamp, the time difference between timestamps 10 seconds.
And the effect I want is to show the first timestamp first, wait 10 seconds, and then show the second timestamp.
So:
I w
File_size and file_size_new to 0. Loop inside update file_size_new file size, it is important to note that PHP to get the file size before you must run the function Clearstatcache (), clear the file state cache, or get the file size may be biased. Calculate add_size = File_size_new-file_size, see if the file size changes, if there is a change, move the file pointer to the specified location, and then output the newly added content, update the file_size value to new_file_size.
The following code, under the current folder, can generate a test.txt and write a timestamp every 20 seconds, regardless of whether the client closes the browser.
Ignore_user_abort (TRUE);
Set_time_limit (0);
function Write_txt () {if (!file_exists ("Test.txt")) {$fp = fopen ("Test.txt", "WB");Fclose ($FP);}$str = file_get_contents (' test.txt ');$str. = "\ r \ n". Date ("H:i:s");$fp = fopen ("Test.txt", "WB");Fwrite ($fp, $STR);Fclose ($FP);}
function Do_cron () {
($bRes) { return true; } If the lock does not succeed, after sleep, the new lock Usleep ($this->ilockretryinterval*1000); } return false; } /* Locking */ Public function Lock ($sLockID) { $oMemcache = $this->connect (); $sKey = $this->slockkeypre. $sLockID; If you don't succeed, you can try a few more times. for ($i = 0; $i The value set here can be set arbitrarily if ($this->addmemcache ($sKey, ' 1 ', $this->ilockcachetimeout)) { return tru
, when flock is executed, the file lock is automatically released.
There is another way
The following code simulates the transaction concurrency status: process1.php
The Code is as follows:
Copy code
$ Num = 100;$ Filename = "processdata.txt ";$ Fp = fopen ($ filename, "");For ($ I = 0; $ I Fwrite ($ fp, "process1:". $ I. "rn ");Usleep (100000 );}Fclose ($ fp );?>
The statement must first execute the first transaction an
:". $ status );If ($ status = 0){// It may be a daemon program that runs in the backgroundIf (file_exists ("/proc/". ($ pid + 1). "/stat ")){// Indicates that the process exists and must be determined regularlyWrite_log ("program start success ");For (;;){If (file_exists ("/proc/". ($ pid + 1). "/stat ")){// Write_log ("program is alive ");Usleep (1000000 );}Else{Write_log ("program die ");Break;}}}Else{// Indicates that the process does not exist and
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.