online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
import Foundation // Image creation simulation func createImage(index: Int) async { print("Creating image \(index)") // Simulate I/O-bound image creation let startTime = Date() let waitTime = Double.random(in: 0.75...1.5) while Date().timeIntervalSince(startTime) < waitTime { // Busy-wait to simulate I/O-bound work } print("Finished creating image \(index)") } // Image processing simulation func processImage(index: Int) async { print("Processing image \(index)") // Simulate CPU-bound image processing let startTime = Date() let waitTime = Double.random(in: 0.75...2.0) while Date().timeIntervalSince(startTime) < waitTime { // Busy-wait to simulate CPU-bound work } print("Finished processing image \(index)") } func processImages(totalCount: Int) async { await withTaskGroup(of: Void.self) { group in for i in 0..<totalCount { group.addTask { await createImage(index: i) } } // Wait for all images to be created await group.waitForAll() for i in 0..<totalCount { group.addTask { await processImage(index: i) } } } print("All images processed") } // Entry point print("Running Image Processing Example:") // Create a semaphore to wait for the async task to complete let completionSemaphore = DispatchSemaphore(value: 0) Task { await processImages(totalCount: 20) completionSemaphore.signal() } // Wait for the async task to complete completionSemaphore.wait() print("Done")

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue