Building
Note: Examples now build directly through native
build compile/build runwithout a priorconfigure. Usebuild configureonly when you explicitly want generated Visual Studio, XCode, or Make projects.
Note: Projects will be generated in
_Build/_Projects. After compiling (SC build compile) executables will be at_Build/_Outputs/${platform}-${arch}-${build}-${compiler}-${config}/${EXAMPLE_NAME}.
SCExample
| Property | Value |
|---|---|
| Location | Examples/SCExample |
| Description | Simple immediate mode gui application using sokol and dear imgui libraries pausing in absence of inputs and I/O to save CPU time |
| Purposes | Use SC::Build to build on macOS, windows and linux and SC::Async as I/O event Loop |
| Use Plugin and FileSystemWatcher libraries implementing hot-reload | |
| Prerequisites | Linux - Fedora: sudo dnf install mesa-libGL-devel mesa-libEGL-devel libX11-devel libXi-devel libXcursor-devel |
Linux - Ubuntu: sudo apt-get install libgles2-mesa-dev libx11-dev libxi-dev libxcursor-dev |
|
| Windows: None | |
| macOS: None | |
| Dependencies | sokol and dear-imgui are automatically downloaded during the first build compile / build run, or during build configure if you are generating projects explicitly |
| Run (Posix) | ./SC.sh build run SCExample (will also compile before running) |
| Run (Windows) | SC.bat build run SCExample (will also compile before running) |
| Run (Native) | ./SC.sh build run SCExample --config Debug or SC.bat build run SCExample --config Debug |
| Debug (VSCode) | Select correct SCExample $ARCH ($PLATFORM) for your system and press Start Debugging (F5) |
| Debug (XCode) | Run ./SC.sh build configure, then open _Build/_Projects/XCode/SCWorkspace/SCWorkspace.xcworkspace and choose the SCExample scheme |
| Debug (VS2022) | Run SC.bat build configure, then open _Build/_Projects/VisualStudio2022/SCWorkspace/SCWorkspace.sln and start Debugging (F5) |
AsyncWebServerExample
| Property | Value |
|---|---|
| Location | Examples/AsyncWebServer |
| Description | Simple Http server listening on port 8090 by default, serving a folder for a static website. |
| Purposes | Show how to create an http server with a runtime configurable set of buffers |
| Prerequisites | Linux: None |
| Windows: None | |
| macOS: None | |
| Dependencies | None |
| Run (Posix) | Examples/AsyncWebServer/BuildAndRun.sh (will also compile before running) |
| Run (Windows) | Examples/AsyncWebServer/BuildAndRun.bat (will also compile before running) |
| Parameters | All parameters can be added after BuildAndRun for example BuildAndRun.sh --directory /somedir: |
--directory /path/to/dir: Serves the given folder |
|
| Debug (XCode) | Run ./SC.sh build configure, then open _Build/_Projects/XCode/SCWorkspace/SCWorkspace.xcworkspace and choose the AsyncWebServer scheme |
| Debug (VS2022) | Run SC.bat build configure, then open _Build/_Projects/VisualStudio2022/SCWorkspace/SCWorkspace.sln and start Debugging (F5) |
Blog
Some relevant blog posts are:
Examples
| Example | Description |
|---|---|
| AwaitBackgroundDigest | Shows ThreadPool-backed CPU work with AwaitEventLoop::loopWork() and caller-owned result jobs |
| AwaitBackgroundJobs | Shows detached background coroutines through fixed caller-owned AwaitTaskRegistry slots |
| AwaitCallbackBridge | Shows callback-style Async and coroutine-style Await sharing one caller-owned event loop |
| AwaitConfigReload | Shows spawnAndWait() for a single child coroutine that loads a config file |
| AwaitDatagramPing | Shows UDP request/reply with AwaitEventLoop::sendTo() and receiveFrom() |
| AwaitDeadline | Shows a child coroutine deadline with waitFor() and cooperative cancellation |
| AwaitEcho | Shows a tiny TCP echo conversation with AwaitTaskGroup and caller-owned allocator storage |
| AwaitFileCourier | Shows file copy followed by AwaitEventLoop::fileSend() over a socket |
| AwaitFilePatch | Shows offset fileWrite() followed by fileRead() using caller-owned buffers |
| AwaitFirstResponse | Races two caller-owned registry jobs with waitAny() and cancels the slower response |
| AwaitLineProtocol | Shows a tiny CRLF text protocol with receiveLine(), sendAll(), and caller-owned allocator storage |
| AwaitManifestPreview | Shows bounded fileReadUntilFullOrEOF() into caller-owned preview storage |
| AwaitProcessExitCodes | Shows concurrent child-process exit waits with processExit() and fixed job storage |
| AwaitServiceProbe | Shows a TCP service probe with task groups, timeout cancellation, and fixed allocator diagnostics |
| AwaitTaskGroupFiles | Shows AwaitTaskGroup fan-out over two file reads with caller-owned task storage |
| AwaitThreadWakeUp | Shows another thread waking an Await coroutine through AwaitLoopWakeUp |
| Serialization | Use Reflection and Serialization to persist application state |
| WebServer | Use Http to statically host a website from a specified directory |
Where can I find more examples?
- The test suite is the closest thing to additional examples you can find in this project.
- The second best thing to do is looking at SC::Tools implementation.
- Documentation for each library has some examples and / or code snippets that you can look at.
Where can I learn more?
There are many way to learn about the library:
- Read the introductory blog post
- Take a look at videos from Youtube Channel
- Read and / or step through the extensive set of unit tests (current test code coverage is > 90%).
- Ask in the Discord
https://github.com/user-attachments/assets/2a38310c-6a28-4f86-a0f3-665dc15b126d https://github.com/Pagghiu/SaneCppLibraries/assets/5406873/5c7d4036-6e0c-4262-ad57-9ef84c214717