Github.com/18023100339… (no fit — it’s best to open it with iPhone11 simulator)
- Course topic: simulation of the process and method of solving “producer-consumer” problem.
- Implement semaphores in C (without GCD semaphore functions) (if only YOU had known that GCD came with semaphores)
- A brief description
- The Producer method uses a while loop to guarantee a “RunLoop” (not NSRunLoop- -), which ensures that the method will continue executing and Sleep for 3 seconds each time, producing a product every 3 seconds. There are also three while loops in the while loop, each of which is responsible for:
- Increases product number by ensuring mutual exclusion through semaphores
- A semaphore is used to block or wake up a thread when the cache pool is full or idle
- Use the cache pool to mutually exclude by semaphore
- The Consumer method uses a while loop to ensure a “RunLoop”, which ensures that the method will continue to execute and Sleep for 3 seconds each time, consuming a product every 3 seconds. There are also three while loops in the while loop, each responsible for:
- Increases product number by ensuring mutual exclusion through semaphores
- A semaphore is used to block or wake up a thread when the cache pool is full or idle
- Use the cache pool to mutually exclude the semaphore
- The Producer and Consumer functions also have a bool variable to determine whether it ends the loop and is used to handle events that cancel the process when the Producer and Consumer functions click.
- After clicking the Add Producer or Consumer button, GCD in iOS development adds the Producer method to the global queue in the asynchronous thread, making it execute concurrently with other threads. Each click adds a Producer method, and it goes back to the main thread for UI update.
- Write more rough forgive me hey hey 🙂
- The Producer method uses a while loop to guarantee a “RunLoop” (not NSRunLoop- -), which ensures that the method will continue executing and Sleep for 3 seconds each time, producing a product every 3 seconds. There are also three while loops in the while loop, each of which is responsible for: