Objetive-C learning _ Block learning notes, objetive-c_block
Block: an anonymous function with an automatic variable (local variable.
Block: used to save a piece of code and can be called when appropriate.
Block essence: struct, which contains a function pointer
Block application scenarios: animation, multithreading, set traversal, and network request callback
Block format: ^ return value type parameter li
The pre-write code encounters a situation where usleep will die under multiple threads.Look at the log is the thread stuck, so gdb went in to see, but did not find the deadlock, or normal stay in the usleep, and finally found that it is usleep in the back.At the end of the week, an experiment was made, and it seemed that the machine had something to do with the o
instancevi. Relationship between OC instance object class object meta-Object(1) Each object is an instance of a class.(2) Each object has a pointer to the object named Isa, which points to its class.(3) Each class describes the characteristics of a series of its instances, including a list of member variables, a list of member functions, and so on.(4) Each object can accept the message, and the message list that the object can receive is saved in the class it corresponds to. Copyright NOTICE: T
Some time ago, during sokcet communication under Objetive-C, when the C ++ program was used as the server, everything was normal. When Java was used as the server, neither party received the data, after reading some documents, sort out the notes
1. Press enter and line feed at the end of the message.
When Objetive-C sends data, add "\ r \ n" to the end"
_ Datatosend = [nsdata datawithbytes: "This is a
atomic operation. If multipleWhen a thread calls the setter at the same time, one thread does not appear before the entire setter statement is executed, and the otherWhen a thread starts executing a setter, it is the same as the method ends with a lock.Nonatomic: The atomicity of Setter/getter is not guaranteed, and data may be problematic in multithreaded situations.nonatomic, non-atomic access, non-synchronous, multi-threaded concurrent access improves performance. First release the originalv
Description of Use
The Usleep command is used to delay the time in microseconds (sleep some number of microseconds), which actually does not reach this precision (Probably not accurate on many machines the mic Rosecond. Count on precision only to-4 or maybe-5.). If there is no usleep command in the system, you can use the Sleep command, and the Sleep command can specify a time delay with a decimal. 1 s
PHP sleep () function, usleep () function, sleepusleep
PHP sleep () function
Definition and usage
The sleep () function delays code execution for several seconds.Syntax sleep (seconds)Seconds required. The pause time in seconds.Return Value
If the call succeeds, 0 is returned. Otherwise, false is returned.Error/exception
If the specified description seconds is a negative number, this function generates an E_WARNING.
Example
Output:
12:00:08 12:00:18
Tag: equals class CPU style note Code strong log IntegerPause code Execution in PHP for a certain time, there are two functions can be implemented, one is sleep (), the other is Usleep (), their parameters are an integer value. Sleep () is how many seconds are paused, and usleep () is how many microseconds are paused.Note: the Usleep () unit is in microseconds, 1
1:sleep ()The minimum unit of seconds.When using Sleep/ulseep/select, because the thread will go to sleep state, and then wake up, if the single execution problem is not small, if the number of cycles executed more, then the difference is very large.2:ulseep ()The smallest unit of microseconds.3:select ()Minimum units of microseconds, which need to be assigned each time they are used in the body.4:RTC ()Use the IOCTL control.5: Examples of use of the above four methods#include #include#includest
1. PHP Sleep () function
Definition and usage
The sleep () function delays code execution for several seconds.Grammar Sleep (seconds)seconds required. The pause time in seconds.return value
If successful, returns 0, otherwise false.Error/exception
If the specified description seconds is a negative number, the function generates a e_warning.
Example
Output:
12:00:08-12:00:18
2. PHP Usleep () function
Definition and usage
The
The use and difference of sleep () and Usleep () for Linux
[Date: 2013-03-23]
Source: Linux Community Fireroll
[Font: Big Small]
Function Name: SleepHeader file: #include #include Function: Execution suspend specified number of secondsSyntax: unsigned sleep (unsigned seconds);Example:#include #include int main (){int A;A=1;printf ("Hello");Sleep (a); /* VC Use sleep*/printf ("World");return 0;}Function Name: Usleep
PHP Sleep () function
Definitions and usage
The sleep () function delays code execution for several seconds.Grammar Sleep (seconds)seconds required. The pause time in seconds.return value
If successful, returns 0, otherwise returns false.Error/exception
If the specified description seconds is a negative number, the function generates a e_warning.
Example
Output:
12:00:08 12:00:18
PHP usleep () function
Definitions and usage
Th
This article mainly introduces the PHPsleep () function and usleep () function. if you need it, refer to the PHP sleep () function.
Definition and usage
The sleep () function delays code execution for several seconds.Syntax sleep (seconds)Seconds required. The pause time in seconds.Return value
If the call succeeds, 0 is returned. otherwise, false is returned.Error/exception
If the specified description seconds is a negative number, this function gen
Definition and usage
The Usleep () function delays code execution for several microseconds.
Grammar
Usleep (microseconds)
Parameter description
microseconds required. Pause time in microseconds.
return value
no return value.
Hints and Notes
Note: This function does not work on Windows systems until PHP 5.Note: One microsecond equals one out of 10,000 seconds.
Example
echo date('h:i:s') . "";//
[RK_2014_0918] in linux, test the impact of usleep function on CPU usage. rk_2014_0918usleep
1. Local Environment
CPU information Intel (R) Core (TM) i3 cpu m 350 @ 2.27 GHz
Intel(R) Core(TM) i3 CPU M 350 @ 2.27GHz
Intel(R) Core(TM) i3 CPU M 350 @ 2.27GHz
Intel(R) Core(TM) i3 CPU M 350 @ 2.27GHz
Memory InformationMemTotal: 1990228 kB
2. Build Test code
1. Test code
#include while (1) { //uslee
Usleep (PHP3, PHP44.0.0) usleep-description of the number of milliseconds in which the voidusleep (intmicro_seconds) usleep () function is paused. for the number of milliseconds specified by micro_seconds, see sleep (). note: This function cannot work in Windows. S
Usleep(PHP 3, PHP 4> = 4.0.0)
Pause code Execution in PHP for a certain time, there are two functions can be implemented, one is sleep (), the other is usleep (), their parameters are an integer value. Sleep () is how many seconds are paused, and usleep () is how many microseconds are paused.
Note:the usleep () unit is in microseconds, 1 seconds = 1000 milliseconds, 1 milliseconds = 100
Pause code Execution in PHP for a certain time, there are two functions can be implemented, one is sleep (), the other is Usleep (), their parameters are an integer value. Sleep () is how many seconds are paused, and usleep () is how many microseconds are paused.
Note:the usleep () unit is in microseconds, 1 seconds = 1000 milliseconds, 1 milliseconds = 100
1. usleep is inaccurate on different hardware platforms, for example, usleep (2*1000). The result is sleep for 10 ms. Is it too much? The test code is as follows:
#include
Of course, to prevent exceptions, you are not allowed to set the system time during the test.
2. Based on previous experience, this usleep is not accurate mainly because the Rating Value of t
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.