C/C++ API Reference
Loading...
Searching...
No Matches
pw_system

Overview

Main docs: Home

Namespaces

namespace  pw::system
 Opinionated system framework.
 

Classes

class  pw::system::AsyncCore
 

Functions

system::AsyncCorepw::System ()
 
void pw::SystemStart (channel::ByteReaderWriter &io_channel)
 
void pw::system::StartAndClobberTheStack (channel::ByteReaderWriter &io_channel)
 
Allocatorpw::system::AsyncCore::allocator ()
 Returns the system pw::Allocator instance.
 
async2::Dispatcherpw::system::AsyncCore::dispatcher ()
 Returns the system pw::async2::Dispatcher instance.
 
rpc::Serverpw::system::AsyncCore::rpc_server ()
 Returns the system pw::rpc::Server instance.
 
bool pw::system::AsyncCore::RunOnce (Function< void()> &&function)
 

Friends

AsyncCorepw::system::AsyncCore::pw::System ()
 
void pw::system::AsyncCore::pw::system::StartAndClobberTheStack (channel::ByteReaderWriter &)
 

Function Documentation

◆ RunOnce()

bool pw::system::AsyncCore::RunOnce ( Function< void()> &&  function)

Runs a function once on a separate thread. If the function blocks, it may prevent other functions from running.

Returns
true if the function was enqueued to run, false if the function queue is full

◆ StartAndClobberTheStack()

void pw::system::StartAndClobberTheStack ( channel::ByteReaderWriter io_channel)

Starts running pw_system:async with the provided IO channel. This function never returns, and depending on the backend it may completely clobber the callers stack so that the scheduled threads can use all of that memory.

Note
Do not call this function if you constructed anything on the stack which must remain intact, such as an RPC service derived from pw::rpc::Service. You should instead either declare those as static or allocate them from the heap to prevent them from being randomly overwritten by this call.
To minimize trouble, we recommend you structure your code to perform all initialization in a function that then returns to main(). Then main() can call StartAndClobberTheStack() with "nothing" on the stack. Even then, the C/C++ runtime initialization may have put values on the stack in order to call main(), and those would be trashed as well.
void main() {
Initialization();
}
void StartAndClobberTheStack(channel::ByteReaderWriter &io_channel)

◆ System()

system::AsyncCore & pw::System ( )
inline

Returns a reference to the global pw_system instance. pw::System() provides several features for applications: a memory allocator, an async dispatcher, and a RPC server.

◆ SystemStart()

void pw::SystemStart ( channel::ByteReaderWriter io_channel)

Starts running pw_system:async with the provided IO channel. This function never returns, and depending on the backend it may completely clobber the callers stack so that the scheduled threads can use all of that memory.

Note
Do not call this function if you constructed anything on the stack which must remain intact, such as an RPC service derived from pw::rpc::Service. You should instead either declare those as static or allocate them from the heap to prevent them from being randomly overwritten by this call.
To minimize trouble, we recommend you structure your code to perform all initialization in a function that then returns to main(). Then main() can call StartAndClobberTheStack() with "nothing" on the stack. Even then, the C/C++ runtime initialization may have put values on the stack in order to call main(), and those would be trashed as well.
void main() {
Initialization();
}
Deprecated:
Use pw::system::StartAndClobberTheStack() for more visibility at the call site. The two functions are otherwise the same.