caching some received data, which is very cumbersome. I have implemented the following simple implementation: part of the code in my encapsulated epoll:
CODE: intMo_epoll_recv (int s, void * buf, int buf_size, int err){Int recved_len = 0;Int total_recv_len = 0;Int count = 0; If (buf = NULL | buf_size {Return-1;} MO_DEBUG ("to recv some data! \ N "); Do{// MO_DEBUG ("call recv, total_recv_len = % d recv_len = % d \ n", total_recv_len, buf_size-total_recv_len );Recved_len = recv (s
pm.max_spare_servers=1000
Passenger's optimized configuration nginx. conf ):
Passenger_max_pool_size 300; // The maximum allowed value of 4 GB memory, and passphrase cannot be started after append.
Create a Test App using a Rails script:
Rails new dummy
Ruby on Rails code:
//app/controller/test_controller.rb
classTestController
defindex
sleep(0.2)
end
end//app/views/test/index.html.rb
PHP code:
//vsruby.php
usl
/*** Write lock test* Open thread 1*/Require ("file_lock.php ");$ Lock = new File_Lock (dirname (_ FILE _). "/FileLock. lock ");/** The lock speed of a single thread is 30 thousand times per second. **//** Two threads write, 20 thousand of the data is about 7 s *//** Write data in one thread. The data size of 10 thousand is about 3.9 s. The two files are written at the same time, which is faster *//** If the lock is not performed, it takes about 2.8 seconds for a process to write data. Locking i
Example of using multiple processes to control file read/write simultaneously in php
This article mainly introduces the example of using multiple processes to simultaneously Control File Read/write in php. For more information, see
The Code is as follows:
/**
* Write data
* @ Param [string] $ path [file path]
* @ Param [string] $ mode [file opening mode]
* @ Param [string] $ data [data]
* @ Return [bool]
*/
Function writeData ($ path, $ mode, $ data ){
$ Fp = fopen ($ path, $ mode );
$ Retries
at 1508058077.6659(s)Log thread 1508058076.6664 at 1508058077.6671(s)
Interestingly, the registration time of the green (simulated) thread and the red (simulated) thread is the same, indicating that the two (simulated) threads are concurrently executed.
2. PHP-FPM configuration item pm. max_children = 10, simulated. thread record as follows:
Log thread 1508061169.7956 at 1508061170.7963(s)Log thread 1508061169.7966 at 1508061170.7976(s)Log thread 1508061169.7978 at 1508061170.7988(s)Log thread
Urgent request: About PHP Real-time output data to the client.
The test code is as follows:
Ob_start ();
for ($i = 1; $i $sourceName = ' filetoupload '. $i;
$imageArray = Array ();
$message = "Image $i have been uploaded to the server";
Echo $message;
Flush ();
Ob_flush ();
Usleep (500000);
}
Ob_end_flush ();
?>
The test results are as follows:
On the local server, the script can run side output, but in the intranet server running is 100 cycles after
doesn't affect the MapPoint pointer in the map. */mappointculling (); Triangulate New Mappoints/* This generates a map point that is not the same as the tracking line thread, where the map point is generated directly using the depth information. This is done again based on the neighbor frame of the current frame, using triangulation to generate the map points. This increases the visible distance of the slam */createnewmappoints (); if (! Checknewkeyframes ()) {//
progress, sleep () or usleep () to control the sleeping time, sleeps for seconds, Usleep for microseconds.6, for The small circle rotated in the load is counterclockwise through "/-|\". Implement the progress bar below650) this.width=650; "title=" 3.png "src=" http://s2.51cto.com/wyfs02/M02/82/4E/ Wkiol1dq7hhzgbjeaabvzmygnce884.png-wh_500x0-wm_3-wmp_4-s_269599084.png "alt=" Wkiol1dq7hhzgbjeaabvzmygnce884.p
always replays the last 0.2 or 0.5 seconds of data. Because only recently ported Dawnlightplayer used Windows, the mechanism was not well understood.static void Dsound_play (Avsample *s){int Wlen, ret, len = s->size;uint8_t *data = s->data;while (Len > 0){Wlen = Dsound_getspace ();if (Wlen > len) wlen = len;RET = Write_buffer (data, Wlen);Data + = RET;Len-= ret;Usleep (10*1000);}}Five. Audio and video synchronization1. Sync video on audio basisThe vi
the system can meet its maximum demand, allocate the resources according to the current amount of requests, or postpone the allocation. When the process continues to request resources in execution, first test the process for the number of resources this request exceeds the total amount remaining for that resource. If the resource is not allocated, the resource will be allocated according to the current application amount, otherwise the allocation will be deferred. Reference: http://blog.csdn.n
For example, the following code can be used for reference:static void _sleep_response_timeout (modbus_t *ctx) {#ifdef _WIN32/ * Usleep doesn ' t exist on Windows */ sleep ( Ctx->response_timeout.tv_sec * + (ctx->response_timeout.tv_usec/1000)); #else/ * Usleep Source Code */ struct TIMESPEC request, remaining; Request.tv_sec = ctx->response_timeout.tv_sec; Request.tv_nsec = ((long
is not reliable, the Apache restart will have to revisit, fastcgi will be better.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);functionWrite_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(
The principles of the experimental design and the format of the test results are briefly explained: In order to ensure the reliability of the results, each group of experiments repeated 20 times, in a single experiment, given the same set of interface URLs, respectively measuring classic (referring to the classical concurrency mechanism) and rolling (refers to the improved concurrency mechanism) The two concurrency mechanisms are time-consuming (in seconds), the short duration wins (Winner), a
The purpose of using a timer is to perform a task periodically, or to perform a task at a specified time. In order to achieve this goal, there are generally two common and more effective methods. One is using the three timer inside Linux, and the other is sleeping or usleep the process to sleep for a while; in fact, there is another way, it is to use Gettimeofday, difftime and so on themselves to calculate the time interval, and then time to do a task
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.