X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=AFBClient.cpp;h=9bcb8804c0686262243dc797189d6561674701db;hb=31768957cd3e7ce3152db910b487ff73b73fffc4;hp=407aeac0ff7b8ad4a7c3e9fda3a63dd8e670c6ba;hpb=b8ec6408f237065d6f87a23bcfe6c20ac56528bf;p=staging%2Fwindowmanager.git 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