sco_api.run_on_game_thread
Any thread. Runs fn(ctx) on the game thread, in order, on the next tick. SCO_TOO_MANY only when 65536 tasks are already waiting (the host’s cap) or memory runs out.
Signature
Section titled “Signature”sco_result (*)(sco_plugin *, sco_task_fn, void *)Service and availability
Section titled “Service and availability”| Property | Value |
|---|---|
| Symbol | sco_api.run_on_game_thread |
| Record ID | sco-api-run-on-game-thread |
| Service | sco_api |
| Table | sco_api |
| Version macro | SCO_API_MAJOR/SCO_API_MINOR |
| Packed table version | 65537 |
| Since / availability | size >= 32; 1.0 |
| Complete member extent (x64 bytes) | 32 |
| Table size (x64 bytes) | 128 |
Parameters and buffers
Section titled “Parameters and buffers”sco_result (*run_on_game_thread)(sco_plugin* self, sco_task_fn fn, void* ctx);
Any thread. Runs fn(ctx) on the game thread, in order, on the next tick. SCO_TOO_MANY only when 65536 tasks are already waiting (the host’s cap) or memory runs out.
Results and failures
Section titled “Results and failures”OK queued; BAD_ARG invalid/released self or NULL fn; TOO_MANY at queue hard cap or allocation failure; no capability gate.
Absent capability
Section titled “Absent capability”unspecified
Ownership
Section titled “Ownership”fn/ctx borrowed until execution or owner release; ctx is not copied/freed. First 256 waiting tasks use fixed ring; overflow allocates nodes up to 65,536 waiting tasks.
Thread affinity
Section titled “Thread affinity”Any thread; reentrancy unspecified.
Callback context
Section titled “Callback context”Runs fn(ctx) on the game thread, in order, on the next tick.
Reentrancy
Section titled “Reentrancy”unspecified
Cleanup and cancellation
Section titled “Cleanup and cancellation”Queued tasks dropped on unload/failed load/crash; no task-specific cancel or drop notification; caller must clean ctx.
Language mappings
Section titled “Language mappings”Status labels are copied verbatim from the catalogue: direct is native access; typed-wrapper is wrapper-backed; restricted is a subset/adaptation; unsupported means no supported route is established. No status implies universal safety.
| Language | Catalogue status | Source evidence / wrapper tokens |
|---|---|---|
| c | direct | include/sco_api.h(*run_on_game_thread) |
| cpp | typed-wrapper | include/scosdk/plugin.hppconst sco_result r = api_->run_on_game_thread(self_, detail::TaskTrampoline, detail::ToCtx(id)); |
| csharp | typed-wrapper | sdk/csharp/Sco.Sdk/Plugin.csScoResult r = a->run_on_game_thread(_self, &TaskTrampoline, (void*)id); |
| lua | restricted | plugins/lua/sco_lua.cconst sco_result r = s->api->run_on_game_thread(s->self, TaskThunk, t);plugins/lua/sco_lua.c if (s->ntasks >= SCO_LUA_MAX_TASKS) return PushResult(L, SCO_TOO_MANY); |
Examples
Section titled “Examples”- tests/abi_v1.c
- tests/test_app.cpp
- tests/test_datacore_service.cpp
- tests/test_host.cpp
- tests/test_ipc.cpp
- tests/test_lua.cpp
- tests/test_net_service.cpp
- tests/test_plugins.cpp
- tests/test_sdk.cpp
- tests/test_settings.cpp
- tests/test_storage.cpp
- tests/test_ui.cpp
- sdk/csharp/Sco.Sdk.Tests/FakeHost.cs
- tools/test.sh
- sdk/csharp/Sco.Sdk.Tests/Layout.cs
Find by task
Section titled “Find by task”schedule game thread task This is a search phrase for the existing contract, not an additional API alias.
ABI pins prove layout, not semantic behavior or a live game session.