Project
Loading...
Searching...
No Matches
WSDriverClient.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef O2_FRAMEWORK_WSDRIVERCLIENT_H_
12#define O2_FRAMEWORK_WSDRIVERCLIENT_H_
13
16#include <uv.h>
17#include <functional>
18#include <memory>
19#include <string>
20#include <vector>
21#include <mutex>
22#include <atomic>
23
24typedef struct uv_connect_s uv_connect_t;
25typedef struct uv_async_s uv_async_t;
26
27namespace o2::framework
28{
29
30struct ServiceRegistry;
31struct DeviceState;
32struct WSDPLClient;
33struct DeviceSpec;
34
39{
40 public:
41 WSDriverClient(ServiceRegistryRef registry, char const* ip, unsigned short port);
43 void tell(const char* msg, size_t s, bool flush = true) final;
44 void flushPending(ServiceRegistryRef mainThreadRef) final;
45 void setDPLClient(std::unique_ptr<WSDPLClient>);
46 void setConnection(uv_connect_t* connection) { mConnection = connection; };
47 // Initiate a websocket session
48 void sendHandshake();
49 std::mutex& mutex() { return mClientMutex; }
50
51 private:
53 void awake();
54 // Whether or not we managed to connect.
55 std::atomic<bool> mConnected = false;
56 std::mutex mClientMutex;
57 ServiceRegistryRef mRegistry;
58 std::vector<uv_buf_t> mBacklog;
59 uv_async_t* mAwakeMainThread = nullptr;
60 uv_connect_t* mConnection = nullptr;
61 std::unique_ptr<WSDPLClient> mClient;
62};
63
64} // namespace o2::framework
65
66#endif // O2_FRAMEWORK_WSDRIVERCLIENT_H_
struct uv_async_s uv_async_t
struct uv_connect_s uv_connect_t
A service API to communicate with the driver.
void setDPLClient(std::unique_ptr< WSDPLClient >)
void tell(const char *msg, size_t s, bool flush=true) final
void flushPending(ServiceRegistryRef mainThreadRef) final
void setConnection(uv_connect_t *connection)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
uint64_t const void const *restrict const msg
Definition x9.h:153