コード例 #1
0
/** [Define sample request processing implementation] */
void
Sample_processor::Process_api_call(int param, ugcs::vsm::Request::Ptr request,
                                   Handler handler)
{
    auto lock = request->Lock();
    if (!request->Is_processing()) {
        /* It might be canceled. */
        return;
    }
    handler.Set_args(param * 2);
    request->Complete(ugcs::vsm::Request::Status::OK, std::move(lock));
}
コード例 #2
0
void
Red_button_processor::Fire_event_handler(Event_id event_id, ugcs::vsm::Request::Ptr req,
                                         Event_handler handler)
{
    Event &event = event_queue[event_id & (EVENT_QUEUE_SIZE - 1)];
    ugcs::vsm::Io_result result =
        event.state == State_code::INITIAL ? ugcs::vsm::Io_result::CLOSED : ugcs::vsm::Io_result::OK;
    bool pressed = event.state == State_code::PRESSED;

    auto lock = req->Lock();
    if (req->Is_processing()) {
        handler.Set_args(pressed, result);
        req->Complete(ugcs::vsm::Request::Status::OK, std::move(lock));
    }
}