adapnex::core::Application::AddStopHandler

Registers a handler to be invoked once when the application is stopping. Use this to unblock a task waiting inside a blocking Task::Update(), for example by calling TCPConnection::Close(). Handlers are invoked in reverse registration order. Tasks that need to release resources or write final values should override Task::TearDown() instead.

Synopsis

Declared in <adapnex/core/application.h>

static
void
AddStopHandler(std::function<void()> handler);

Description

May be called from any thread at any time. A handler registered after the handlers of an ongoing shutdown have already run is invoked immediately.

Unlike the methods of Task, the handler is invoked from a separate thread, concurrently with tasks that are still running. It must therefore be thread‐safe with respect to the task it interacts with, it must return promptly, and it has no Context available (timers cannot be used).

Parameters

Name

Description

handler

The function to be called when the application is stopping.

Created with MrDocs