3#ifndef _FRAY_IPC_MANAGER_HPP_
4#define _FRAY_IPC_MANAGER_HPP_
6#include <boost/asio.hpp>
15#include <condition_variable>
37 using Frame = std::shared_ptr<const std::vector<F_uchar>>;
39 using Socket = std::shared_ptr<boost::asio::ip::tcp::socket>;
50 class TCPServer :
public std::enable_shared_from_this<TCPServer>
66 std::set<std::shared_ptr<boost::asio::ip::tcp::socket>>
_sessions;
72 std::map<std::shared_ptr<boost::asio::ip::tcp::socket>,
83 std::shared_ptr<boost::asio::ip::tcp::socket> session);
97 std::shared_ptr<boost::asio::ip::tcp::socket> session);
115 boost::asio::io_context &ctx,
164 if (!session || !frame)
169 write(std::move(session), std::move(frame));
189 boost::asio::io_context
_io;
220 std::function<std::vector<std::string>()>
_fontReader = [] {
return std::vector<std::string>(); };
260 std::chrono::steady_clock::time_point
_lastProgress = std::chrono::steady_clock::now();
288 const auto previous =
_outgoing.state(neighbor);
299 if (!(neighbor.first == PROCESS_KIND_ELECTRON_MAIN && neighbor.second == 0 &&
302 if (neighbor.first == PROCESS_KIND_ELECTRON_MAIN && neighbor.second == 0)
303 _application.cancelPrompts(
"Electron Main is unavailable.");
369 for (
const auto &s : servers)
389 throw std::logic_error(
"Cannot create a server after IPC shutdown.");
390 auto s = std::make_shared<TCPServer>(
_io, port,
this);
406 { return sp && sp->port() == port; });
453 const std::string &name,
454 const std::string &version)
458 info.set_version(version);
461 options.
payload = info.SerializeAsString();
474 std::uint32_t windowId)
477 target.set_window_id(windowId);
479 options.
payload = target.SerializeAsString();
491 const std::string &name,
492 const std::string &version)
499 _startupActive = true;
500 _startupFailed = false;
501 _loadingIntroElapsed = false;
502 _startupMilestones = engineStarted;
504 if (_outgoing.isReady({PROCESS_KIND_ELECTRON_MAIN, 0}))
521 std::function<std::vector<std::string>()> reader)
533 auto families = std::make_shared<std::vector<std::string>>(
_fontReader());
536 _systemFonts = std::move(*families);
537 _systemFontsLoaded = true;
538 fray::log::engineInfo(
"Read %zu installed font families.", _systemFonts.size());
539 if (_outgoing.isReady({PROCESS_KIND_ELECTRON_RENDERER, message::MAIN_WINDOW_ID}))
550 SystemFonts fontList;
552 fontList.add_families(family);
554 options.
payload = fontList.SerializeAsString();
557 options.
flags = MESSAGE_FLAG_NO_CONSOLE;
580 boost::asio::post(
_io, [
this]
585 if (error == boost::asio::error::operation_aborted)
return;
588 if (!_startupActive || _startupFailed ||
589 _application.shutdownPhase() != FrayManager::ShutdownPhase::running) return;
592 startupFailed(
"Loading intro timer failed: " + error.message());
608 const std::string &status =
"")
610 unsigned completed = 0;
613 StartupProgress progress;
615 _outgoing.isReady({PROCESS_KIND_ELECTRON_MAIN, 0}) &&
616 _outgoing.isReady({PROCESS_KIND_ELECTRON_RENDERER, message::MAIN_WINDOW_ID});
621 progress.set_status(status);
624 options.
payload = progress.SerializeAsString();
626 options.
messageType = MESSAGE_TYPE_STARTUP_PROGRESS;
644 _outgoing.isReady({PROCESS_KIND_ELECTRON_MAIN, 0}) &&
645 _outgoing.isReady({PROCESS_KIND_ELECTRON_RENDERER, message::MAIN_WINDOW_ID});
657 !
_outgoing.isReady({PROCESS_KIND_ELECTRON_MAIN, 0}) ||
658 !
_outgoing.isReady({PROCESS_KIND_ELECTRON_RENDERER, message::MAIN_WINDOW_ID}))
671 const std::string &error)
690 boost::asio::post(
_io, [
this, generation]
693 _startupTimer.async_wait([
this, generation](
const boost::system::error_code &error)
695 if (error == boost::asio::error::operation_aborted)
return;
703 if (generation != _startupWarningGeneration || !_startupActive || _startupFailed ||
704 _application.shutdownPhase() != FrayManager::ShutdownPhase::running) return;
705 fray::log::engineWarn(
"Application startup is taking longer than expected.");
706 sendStartupProgress(
"Startup is taking longer than expected.");
736 _monitorTimer.async_wait([
this](
const boost::system::error_code &error)
738 if (error == boost::asio::error::operation_aborted)
return;
770 boost::asio::post(
_io, [
this]
773 _shutdownTimer.async_wait([
this](
const boost::system::error_code& error)
798 message::FrameOptions quit{PROCESS_KIND_ELECTRON_MAIN, COMMAND_QUIT};
801 if (result != errors::NONE)
815 boost::asio::post(
_io, [
this, identified]
818 for (
const auto& server : servers)
820 server->broadcast(identified);
821 for (
const auto& server : servers)
823 server->drainAndStop();
827 _shutdownCommandSent =
false;
861 boost::asio::post(
_io, [
this]()
864 for (
const auto &s : servers)
885 if (!
_messages.post([
this, frame = std::move(frame)]() { route(frame); }))
903 if (err != errors::NONE)
908 send(std::move(frame));
917 ProcessKind destination,
921 options.
category = MESSAGE_CATEGORY_MESSAGE;
940 catch (
const std::runtime_error& error)
945 catch (
const std::bad_alloc& error)
961 const auto& prefix = incoming.
prefix;
970 for (
const auto& recipient : incoming.
header.recipients())
972 if (recipient.kind() == PROCESS_KIND_ENGINE && recipient.id() == 0)
974 else if ((recipient.kind() == PROCESS_KIND_ELECTRON_MAIN && recipient.id() == 0) ||
975 recipient.kind() == PROCESS_KIND_ELECTRON_RENDERER)
980 static_cast<int>(recipient.kind()), recipient.id());
987 if (record && tracked)
995 receipt.set_flags(incoming.
header.flags());
996 receipt.set_sender(
static_cast<ProcessKind
>(prefix.senderKind));
997 receipt.set_destination(PROCESS_KIND_MULTICAST);
998 receipt.set_operation(prefix.operationId);
1000 options.
category = MESSAGE_CATEGORY_MESSAGE;
1001 options.
payload = receipt.SerializeAsString();
1004 if (incoming.
header.has_target_project())
1017 auto local = incoming;
1019 local.prefix.destinationId = 0;
1020 if (prefix.category == MESSAGE_CATEGORY_COMMAND)
1025 fray::log::engineWarn(
"Cannot handle multicast protocol message: unknown id=%u.", prefix.operationId);
1027 if (remote && !
_outgoing.send({PROCESS_KIND_ELECTRON_MAIN, 0}, incoming.
frame, incoming.
header.ttl_ms()) &&
1048 if (err != fray::errors::NONE)
1054 outgoing.
frame = identified;
1055 const auto &prefix = outgoing.
prefix;
1056 if (prefix.destinationKind == PROCESS_KIND_MULTICAST)
1058 routeMulticast(outgoing, prefix.senderKind == PROCESS_KIND_ENGINE);
1063 if (prefix.senderKind == PROCESS_KIND_ENGINE &&
1064 (prefix.destinationKind == PROCESS_KIND_ELECTRON_MAIN || prefix.destinationKind == PROCESS_KIND_ELECTRON_RENDERER) &&
1074 else if (!
_outgoing.send({prefix.destinationKind, prefix.destinationId}, identified, outgoing.
header.ttl_ms()) &&
1090 boost::asio::post(
_io, [
this, frame = std::move(frame)]()
1094 s->broadcast(frame); });
1108 const auto &prefix = incoming.
prefix;
1109 if (prefix.senderKind == PROCESS_KIND_ENGINE || prefix.senderKind == PROCESS_KIND_BROADCAST)
1111 const Neighbor sender{prefix.senderKind, prefix.senderId};
1114 const bool wasReady =
_outgoing.isReady(sender);
1120 if (sender.first == PROCESS_KIND_ELECTRON_MAIN && sender.second == 0 &&
_outgoing.isReady(sender))
1125 if (sender.first == PROCESS_KIND_ELECTRON_RENDERER &&
1131 if (!wasReady &&
_outgoing.isReady(sender))
1135 sendReady(prefix.senderKind, prefix.senderId);
1140 sendReady(prefix.senderKind, prefix.senderId);
1144 HealthReport report;
1147 report.set_progress_age_ms(std::chrono::duration_cast<std::chrono::milliseconds>(
1149 for (
const auto &queue :
_outgoing.queueHealth())
1151 auto *item = report.add_queues();
1152 item->set_destination(queue.destination.first);
1153 item->set_destination_id(queue.destination.second);
1154 item->set_depth(queue.depth);
1155 item->set_oldest_age_ms(queue.oldestAgeMs);
1158 options.
payload = report.SerializeAsString();
1166 HealthReport report;
1167 if (incoming.
header.payload_type() != PAYLOAD_TYPE_PROTOBUF ||
1168 incoming.
header.message_type() != MESSAGE_TYPE_HEALTH_REPORT ||
1169 !report.ParseFromArray(incoming.
payload(),
static_cast<int>(incoming.
payloadSize())))
1176 report.processed_count(), report.progress_age_ms(), report.heartbeat(), {}};
1177 for (
const auto &queue : report.queues())
1178 health.
queues.push_back({{queue.destination(), queue.destination_id()}, queue.depth(), queue.oldest_age_ms()});
1179 _monitor.report(sender, std::move(health));
1197 if (!
_messages.post([
this, frame = std::move(frame)]()
1199 message::Prefix prefix;
1200 F_err err = message::decodePrefix(frame->data(), frame->size(), prefix);
1201 if (err != fray::errors::NONE)
1203 fray::log::engineError(
"Message processing failed: %s", fray::errors::description(err));
1206 const bool multicast = prefix.destinationKind == PROCESS_KIND_MULTICAST;
1214 if (err != fray::errors::NONE)
1243 _application.handleApplicationMessage(incoming, *
this);
1246 else if (prefix.category == MESSAGE_CATEGORY_MESSAGE && !
message::isNotice(prefix, MSG_READY))
1260 auto self = shared_from_this();
1264 boost::system::error_code ec,
1265 boost::asio::ip::tcp::socket sock)
1271 auto session = std::make_shared<boost::asio::ip::tcp::socket>(std::move(sock));
1282 std::shared_ptr<boost::asio::ip::tcp::socket> session)
1284 auto self = shared_from_this();
1285 auto prefixBytes = std::make_shared<std::array<F_uchar, message::PREFIX_SIZE>>();
1286 boost::asio::async_read(
1288 boost::asio::buffer(*prefixBytes),
1289 [
this, self, session, prefixBytes](
1290 boost::system::error_code ec,
1291 std::size_t bytesRead)
1295 if ((ec != boost::asio::error::eof || bytesRead != 0) && ec != boost::asio::error::operation_aborted)
1303 if (err != errors::NONE)
1316 std::copy(prefixBytes->begin(), prefixBytes->end(), frame->begin());
1318 boost::asio::async_read(
1320 [
this, self, session, frame](
1321 boost::system::error_code ec2,
1326 if (ec2 != boost::asio::error::operation_aborted)
1327 fray::log::engineError(
"Failed to read message body: %s", ec2.message().c_str());
1328 closeSession(session);
1333 _manager->queueMessage(std::move(frame));
1346 for (
const auto &session : sessions)
1347 write(session, frame);
1351 std::shared_ptr<boost::asio::ip::tcp::socket> session,
1355 queue.push_back(std::move(frame));
1357 if (queue.size() == 1)
1362 std::shared_ptr<boost::asio::ip::tcp::socket> session)
1364 const auto found =
_outgoing.find(session);
1365 if (found ==
_outgoing.end() || found->second.empty())
1367 auto frame = found->second.front();
1368 auto self = shared_from_this();
1369 boost::asio::async_write(
1371 boost::asio::buffer(*frame),
1372 [
this, self, session, frame](boost::system::error_code ec, std::size_t)
1376 if (ec != boost::asio::error::operation_aborted)
1381 const auto pending =
_outgoing.find(session);
1384 pending->second.pop_front();
1394 boost::system::error_code ec;
1406 if (!queue.second.empty())
1419 boost::system::error_code ec;
1422 _drainTimer.expires_after(std::chrono::seconds(1));
1423 auto self = shared_from_this();
1424 _drainTimer.async_wait([
this, self](
const boost::system::error_code& error)
1426 if (error == boost::asio::error::operation_aborted)
1444 boost::system::error_code ec;
1454 boost::system::error_code sec;
1455 s->shutdown(boost::asio::ip::tcp::socket::shutdown_both, sec);
Owns and coordinates projects, their queues, application work, prompts, and logs. Project work runs o...
Owns the TCP servers and the threads around them.
unsigned _startupMilestones
F_void advanceShutdown()
Advances Engine-local shutdown and sends Main an independent terminal command when ready.
F_void armShutdownPoll()
Advances shutdown now and re-arms the poll on the network thread while it is still pending.
F_void queueMessage(Frame frame)
Called by the network thread: queues a received message for the engine message thread....
F_void sendSystemFonts()
Message thread only. Sends the installed font families to the application Renderer,...
bool _loadingIntroElapsed
F_void removeTCPServer(F_ushort port)
Forgets the server on the port (called by TCPServer::stop on the network thread). When no servers rem...
std::function< std::vector< std::string >()> _fontReader
boost::asio::steady_timer _startupTimer
F_void finishStartupIfReady()
Transitions only after startup milestones and the loading intro timer have both finished.
F_void setFontReader(std::function< std::vector< std::string >()> reader)
Sets how installed font families are listed during startup. Call before startLoading().
Frame identify(const Frame &frame, message::Prefix &prefix)
Assigns a routing UID without preventing delivery if UID generation fails.
static constexpr unsigned allStartupMilestones
std::atomic< bool > _startupMainPending
Keeps the initial startup queue until Main first announces readiness.
threads::ThreadManager::Id _networkThread
IPCManager(threads::ThreadManager &threads, FrayManager &application)
Creates an IPCManager whose threads register with a ThreadManager owned by someone else.
~IPCManager()
Finishes IPC and application shutdown if not already finished.
F_void route(const Frame &frame)
Router thread only. Delivers an outgoing frame, or queues it if its destination is not ready....
F_void sendLoadingBuildInfo(const std::string &name, const std::string &version)
Queues build information for the loading Renderer without waiting for it to start.
F_void networkFinished()
Marks the network thread as finished and wakes wait(). Takes _networkMutex briefly....
static constexpr unsigned startupMilestoneCount
F_void transmit(Frame frame)
Writes a frame to every connected client. Safe from any thread (posts to the network thread).
F_void start()
Starts the network thread and the engine message thread, then returns. Does nothing if already starte...
F_void sendReady(ProcessKind destination, F_ulong destinationId)
Sends a readiness notification without waiting for the destination.
threads::ThreadManager * _threads
FrayManager & _application
F_void routeMulticast(const message::InData &incoming, bool record)
Records one multicast command, handles the Engine recipient, and queues one frame to Main.
F_void stop()
Asks every server to stop (run on the network thread). Safe from any thread; wait() returns once the ...
F_void mainFrameIsReady()
Records Main's announcement that the application window has a first frame.
threads::TaskQueue _messages
F_void startupFailed(const std::string &error)
Records Main's independent report that application-window startup failed.
F_void pollShutdown()
Starts a short-interval local poll that advances shutdown until its terminal command is queued....
routing::NeighborMonitor< Neighbor > _monitor
unsigned _startupWarningGeneration
std::unique_ptr< threads::ThreadManager > _ownedThreads
boost::asio::steady_timer _monitorTimer
F_void scheduleLoadingIntro()
Starts the Engine-owned, nonblocking loading logo intro timer.
F_void startLoading(const std::string &name, const std::string &version)
Queues the initial hidden loading window and its application information.
threads::ThreadManager::Id _fontsThread
F_void scheduleStartupWarning()
Warns about slow startup without completing it or blocking any process.
F_void sendWindowCommand(F_ulong operation, std::uint32_t windowId)
Queues a window operation for Electron Main.
routing::OutgoingRouter< Neighbor, Frame > _outgoing
bool send(Frame frame)
Hands a message to the router and returns at once. Safe from any thread. The router delivers it now i...
bool _shutdownCommandSent
boost::asio::steady_timer _shutdownTimer
IPCManager(FrayManager &application)
Creates an IPCManager with its own ThreadManager, which is convenient for tests.
F_void readSystemFonts()
Reads the installed font families on a worker thread, then hands them to the message thread,...
bool loadingWindowActive() const
Whether startup logs should include the loading window.
bool _shutdownConsoleStarted
F_void recordStartupMilestone(unsigned milestone)
Records an independent startup event and advances the Engine-owned transition.
std::condition_variable _networkWake
F_void sendBuilt(const message::FrameOptions &options)
Builds an Engine frame from the options and sends it with send(). Safe from any thread....
std::atomic< bool > _loadingWindowActive
std::chrono::steady_clock::time_point _lastProgress
static constexpr auto loadingIntroDuration
std::vector< std::string > _systemFonts
std::vector< TCPServerSP > _servers
std::pair< ProcessKind, F_ulong > Neighbor
TCPServerSP createTCPServer(F_ushort port)
Creates a TCP server and starts it accepting. Must be called before start(). Not thread-safe; call fr...
threads::ThreadManager::Id _messageThread
boost::asio::io_context _io
boost::asio::steady_timer _loadingIntroTimer
F_void scheduleMonitor()
Arms the one-second monitor timer; each firing queues a router sweep and neighbor-monitor tick on the...
F_void handleReadiness(const message::InData &incoming)
Message thread only. Handles readiness and health traffic from a neighbor. A READY marks the sender r...
F_void finish()
Stops IPC, releases servers, and shuts the application down exactly once. Call on the controlling thr...
F_void wait()
Blocks until every server has stopped and the queued messages have been handled. While waiting it pos...
F_void sendStartupProgress(const std::string &status="")
Publishes the Engine's startup snapshot to the loading Renderer.
F_void loadingReadyToShow()
Records loading readiness and independently commands both startup windows.
TCPServer(boost::asio::io_context &ctx, F_ushort port, IPCManager *manager)
Binds a listening IPv4 socket on the port. Throws (boost) if the port cannot be bound.
F_void startRead(std::shared_ptr< boost::asio::ip::tcp::socket > session)
Reads one frame (prefix, then header + payload) from the client and hands it to IPCManager::queueMess...
F_void accept()
Starts (and re-arms) an asynchronous accept; each client gets a session and starts being read....
F_void drainAndStop()
Stops accepting and drains queued socket writes for at most one second. Network thread only.
boost::asio::ip::tcp::acceptor _acceptor
F_void sendTo(Socket session, Frame frame)
Queues a message for one client. Network thread only. Logs an error and sends nothing if session or f...
~TCPServer()
Logs that the server was destroyed.
F_void setConnectionHandler(ConnectionHandler handler)
Sets the callback run on the network thread for each accepted client. Set before start().
F_void stop()
Stops accepting, closes every client, drops pending writes and asks the owning IPCManager to remove t...
F_ushort port() const
The port the server is listening on (the OS-chosen one if 0 was requested).
ConnectionHandler _connectionHandler
F_void write(Socket session, Frame frame)
Appends a frame to the session's write queue and starts writing if none is in flight.
boost::asio::steady_timer _drainTimer
F_void closeSession(Socket session)
Closes the client socket and forgets its session and pending writes (queued frames are lost).
std::map< std::shared_ptr< boost::asio::ip::tcp::socket >, std::deque< Frame > > _outgoing
std::set< std::shared_ptr< boost::asio::ip::tcp::socket > > _sessions
F_void broadcast(Frame frame)
Queues a message for every connected client. Network thread only; use IPCManager::send elsewhere.
F_void start()
Begins accepting clients (called by IPCManager::createTCPServer). Network thread / before the io_cont...
F_void writeNext(std::shared_ptr< boost::asio::ip::tcp::socket > session)
Writes the frame at the front of the session's queue; on completion pops it and writes the next....
F_void stopIfDrained()
Stops the server once all locally queued writes have completed.
Keeps lines in the persistent log but out of the Console for this thread's scope.
Builds outgoing frames sent by the Engine (sender is always the Engine). Stateless; safe to use from ...
F_err build(const FrameOptions &options, std::shared_ptr< const std::vector< F_uchar > > &out) const
Builds an Engine frame from the options, stamping the protocol version, a new message id and the curr...
Tracks neighbor liveness and health from what the router hears, and reports state transitions....
The router thread's single source of truth about which neighbors are ready, plus the messages waiting...
Cooperative cancellation shared by every copy of a token. Copies share one state guarded by an intern...
A task loop that runs on one thread. Other threads post work to it. Tasks run one at a time in postin...
Registry of the engine's threads: starts them, names them, asks them to stop and joins them....
std::uint64_t Id
Handle for a spawned thread; ids start at 1 and are never reused.
F_long F_err
Error return type used across the Engine; the value is a fray::errors::code (0 / NONE means success).
const F_char * description(code err)
Formats an error code as "Error <number>: <description>". Not thread-safe: the text lives in a shared...
std::string hex(const Uid &uid)
Formats a routing UID as lowercase hexadecimal.
std::shared_ptr< TCPServer > TCPServerSP
Shared pointer to a TCPServer.
std::shared_ptr< const std::vector< F_uchar > > Frame
Shared, immutable, fully built frame (prefix + header + payload); shared between threads without copy...
std::shared_ptr< boost::asio::ip::tcp::socket > Socket
Shared TCP client socket; only the network thread may use it.
std::function< void(Socket)> ConnectionHandler
Callback invoked on the network thread with each newly accepted client socket.
F_void engineInfo(const F_char *fmt,...)
Log info for Engine.
F_void engineError(const F_char *fmt,...)
Log error for Engine.
F_void engineWarn(const F_char *fmt,...)
Log warning for Engine.
bool isCommand(const Prefix &prefix, F_ulong id)
Tests whether a prefix identifies a command.
F_err decodePrefix(const F_uchar *data, size_t size, Prefix &out)
Parses and validates a prefix from received bytes.
const char * processName(ProcessKind kind)
Human-readable name of a process kind, also used as the header sender/destination name.
F_err parseFrame(std::shared_ptr< const std::vector< F_uchar > > frame, InData &out)
Parses the header of a complete frame. The payload is not read or copied.
std::shared_ptr< const std::vector< F_uchar > > assignUid(const std::shared_ptr< const std::vector< F_uchar > > &frame, Prefix &prefix)
Assigns a random 128-bit UID to a frame whose prefix does not have one. Existing UIDs are preserved; ...
constexpr std::uint32_t SILENT_FLAGS
bool validMulticastRecipients(const Header &header)
Validates the explicit destinations of a multicast header.
bool isControl(const Prefix &prefix)
Identifies readiness and health control frames.
constexpr std::uint32_t MAIN_WINDOW_ID
Renderer instance ID assigned to the first application window.
constexpr size_t PREFIX_SIZE
Size in bytes of the fixed binary routing prefix.
constexpr std::uint32_t LOADING_WINDOW_ID
Renderer instance ID assigned to the loading window.
std::string processInstanceName(ProcessKind kind, std::uint32_t id)
Names a process instance for readiness diagnostics.
bool isTracked(const Prefix &prefix, std::uint32_t flags)
Identifies messages the Engine router logs, shows in the Console, or both.
bool isNotice(const Prefix &prefix, F_ulong id)
Tests whether a prefix identifies a protocol notification.
Destination routeMessage(const message::Prefix &prefix)
Decides where an incoming message goes from its prefix destination. Pure apart from logging; may run ...
NeighborState
Readiness of a neighbor process as seen by the router. unknown: nothing known yet; probing: readiness...
MonitorCommand
What the monitor asks its Send callback to transmit: probe = ask for readiness, ping = request a heal...
Destination
Where an incoming message should be handled.
Everything FrameBuilder needs to build one outgoing Engine message.
std::optional< std::string > targetProject
A parsed incoming message. The payload is a view into the frame, which this keeps alive via shared ow...
size_t payloadSize() const
Payload length in bytes (prefix.length minus headerLength).
std::shared_ptr< const std::vector< F_uchar > > frame
const F_uchar * payload() const
Pointer to the first payload byte inside frame (valid only while frame is held; frame must be non-nul...
Fixed-size routing prefix at the start of every frame; routers read only this. All integers are big-e...
ProcessKind destinationKind
std::vector< QueueHealth > queues
uint16_t F_ushort
Unsigned 16-bit integer (used for ports).
uint32_t F_ulong
Unsigned 32-bit integer.
void F_void
Alias for void.
bool F_bool
Alias for bool.