Bredbandskollen CLI  1.2
Asynchronous network task engine
threadbridge.h
1 // Copyright (c) 2018 IIS (The Internet Foundation in Sweden)
2 // Written by Göran Andersson <initgoran@gmail.com>
3 
4 #pragma once
5 
6 #include "bridgetask.h"
7 #include "msgqueue.h"
8 
12 class ThreadBridge : public BridgeTask {
13 public:
14  ThreadBridge(Task *agent = nullptr, double tick=0.05);
15 
17  void pushToAgent(const std::string &msg)
18 
19 
24  std::string popFromAgent();
25 
27  void sendMsgToClient(const std::string &msg) override;
28 
30  double start() override;
31 
33  double timerEvent() override;
34 private:
35  MsgQueue<std::string> method_queue, event_queue;
36  double tick_len;
37 };
Tasks may use a bridge to communicate with an application running outside the event loop.
Definition: bridgetask.h:43
The purpose of a task is to manage socket connections, and/or to execute timers.
Definition: task.h:39
Bridge using a thread safe queue to enable communication between agent and client.
Definition: threadbridge.h:12
double timerEvent() override
Push queued messages for the agent. Called every tick seconds.
Definition: threadbridge.cpp:17
double start() override
Initiate timer to be called after tick seconds.
Definition: threadbridge.cpp:12
void pushToAgent(const std::string &msg) std void sendMsgToClient(const std::string &msg) override
API for client to send message to the agent.
Definition: threadbridge.h:27