From: Marcus Fritzsch Date: Fri, 1 Sep 2017 10:55:56 +0000 (+0200) Subject: AFBClient: trace dispatch_internal(), header hygiene X-Git-Tag: 4.99.1~49 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=staging%2Fwindowmanager.git;a=commitdiff_plain;h=31768957cd3e7ce3152db910b487ff73b73fffc4 AFBClient: trace dispatch_internal(), header hygiene Signed-off-by: Marcus Fritzsch --- diff --git a/AFBClient.cpp b/AFBClient.cpp index 407aeac..9bcb880 100644 --- a/AFBClient.cpp +++ b/AFBClient.cpp @@ -6,8 +6,18 @@ #include #include #include + #include +#include + +#include + +extern "C" { +#include +#include +} + #define UNUSED(x) (void)(x) namespace { @@ -28,14 +38,14 @@ constexpr const char *const wmAPI = "winman"; ScopeTrace __attribute__((unused)) CONCAT(named_trace_scope_, __LINE__)(#N) struct ScopeTrace { - static int indent; + thread_local static int indent; char const *f{}; ScopeTrace(char const *func) : f(func) { fprintf(stderr, "%*s%s -->\n", 2 * indent++, "", this->f); } ~ScopeTrace() { fprintf(stderr, "%*s%s <--\n", 2 * --indent, "", this->f); } }; -int ScopeTrace::indent = 0; +thread_local int ScopeTrace::indent = 0; #endif /* called when wsj1 receives a method invocation */ @@ -73,6 +83,15 @@ void onHangup(void *closure, afb_wsj1 *wsj1) { exit(0); } +static struct afb_wsj1_itf itf = { + onHangup, onCall, onEvent, +}; + +void dispatch_internal(AFBClient *c, uint64_t timeout) { + TRACE(); + c->dispatch(timeout); +} + } // namespace AFBClient &AFBClient::instance() { @@ -81,12 +100,7 @@ AFBClient &AFBClient::instance() { return obj; } -AFBClient::AFBClient() : wsj1{}, itf{}, loop{} { - TRACE(); - itf.on_hangup = onHangup; - itf.on_call = onCall; - itf.on_event = onEvent; -} +AFBClient::AFBClient() : wsj1{}, loop{} { TRACE(); } AFBClient::~AFBClient() { TRACE(); @@ -267,7 +281,7 @@ int AFBClient::call(const char *verb, json_object *object, // if events get triggered by the call (and would be dispatched before // the actual call-reply). while (!returned) { - dispatch(-1); + dispatch_internal(this, -1); } // return the actual API call result diff --git a/AFBClient.h b/AFBClient.h index a31479c..c6da6f7 100644 --- a/AFBClient.h +++ b/AFBClient.h @@ -1,16 +1,13 @@ #ifndef AFBCLIENT_H #define AFBCLIENT_H -#include - #include extern "C" { -#include - -#include "afb-wsj1.h" -#include "afb-ws-client.h" + struct json_object; + struct afb_wsj1; + struct sd_event; } class AFBClient @@ -46,13 +43,10 @@ public: std::function f); private: - /// object will be json_object_put int call(const char *verb, json_object *object, std::function onReply); struct afb_wsj1 *wsj1; - struct afb_wsj1_itf itf; - - sd_event *loop; + struct sd_event *loop; }; #endif // AFBCLIENT_H