SteamExecutor
public final class SteamExecutor: SerialExecutor, Sendable
An executor for associating actors with Steamworks
EXPERIMENTAL
This creates a single new thread to run Actor
/Task
Task
code and periodically
call Steamworks – either to dispatch callbacks or do Steamworks maintenance work.
A single executor thread can support multiple APIClient
s so you can service a
gameserver and client API from the same thread.
This solves the problem of using Swift concurrency with Steamworks outside of the main thread.
Problems:
- The poll resolution promised by the API is dubious – probably because of the
thread priorities available via
NSThread
getting anything below 100ms is a bit sketchy.
To Do (perhaps):
- Change the API clients at runtime - eg. creation of a server or something
- Figure out what on earth is wrong with Linux vs. swift-atomics (or more likely move to built-in atomics)
Topics
Lifecycle
struct APIClient
struct APIClient
init(apiClients: [APIClient], qos: QualityOfService, name: String)
init(apiClients: [APIClient], qos: QualityOfService, name: String)
Create a new Steamworks-focussed executor
Declaration
public init(
apiClients: [APIClient], qos: QualityOfService = .default,
name: String = "SteamExecutor")
Parameters
apiClients |
Description of Steamworks tasks to perform on this thread. |
qos |
The |
name |
A name for the executor’s thread, used in stats and debug. |
init(apiClient: APIClient, qos: QualityOfService, name: String)
init(apiClient: APIClient, qos: QualityOfService, name: String)
Create an executor to service a single Steam API client.
Declaration
public convenience init(
apiClient: APIClient, qos: QualityOfService = .default,
name: String = "SteamExecutor")
func stop()
func stop()
Stop the executor.
Blocks until the thread has finished any pending jobs. If any actors still exist associated with this then they will stop working in a bad way.
Declaration
public func stop()
Properties
var qos: QualityOfService
var qos: QualityOfService
The QualityOfService
QualityOfService
used by the executor’s thread
Declaration
public let qos: QualityOfService
var name: String
var name: String
The (debug) name associated with the executor’s thread and locks
Declaration
public let name: String
var thread: Thread?
var thread: Thread?
Statistics
struct Stats
struct Stats
Statistics about the executor and its API clients
Declaration
public struct Stats
var stats: Stats
var stats: Stats