dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
Promise.hpp
1// Copyright (c) 2025 Devexperts LLC.
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include "../detail/Conf.hpp"
7
8DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)
9
10#include "../exceptions/JavaException.hpp"
11#include "../detail/Concepts.hpp"
12#include "../detail/Math.hpp"
13
14#include <atomic>
15#include <chrono>
16#include <memory>
17#include <utility>
18#include <vector>
19
20/**
21 * \defgroup dxfcpp_promise "Promise" Module
22 * \ingroup dxfcpp_modules
23 * @{
24 */
25
26DXFCPP_BEGIN_NAMESPACE
27
28struct EventType;
29struct JavaException;
30struct Promises;
31
32/// The description of the request of a promise: it is added to the text of the timeout exception. Defined in src/.
33struct PromiseContext;
34
35struct DXFCPP_EXPORT PromiseImpl {
36 protected:
37 std::atomic<void *> handle = nullptr;
38
39 public:
40 /// The description of the request that created the promise; empty for the promises without one. Immutable.
41 std::shared_ptr<const PromiseContext> context{};
42
43 explicit PromiseImpl(void *promiseHandle, std::shared_ptr<const PromiseContext> promiseContext = {});
44
45 bool isDone() const;
46 bool hasResult() const;
47 bool hasException() const;
48 bool isCancelled() const;
49 JavaException getException() const;
50 void await() const;
51 void await(std::int32_t timeoutInMilliseconds) const;
52 bool awaitWithoutException(std::int32_t timeoutInMilliseconds) const;
53 void cancel() const;
54};
55
56struct DXFCPP_EXPORT VoidPromiseImpl : PromiseImpl {
57 std::atomic<void *> handle = nullptr;
58 std::atomic<bool> own = true;
59
60 explicit VoidPromiseImpl(void *promiseHandle, bool isOwned = true,
61 std::shared_ptr<const PromiseContext> promiseContext = {});
62 ~VoidPromiseImpl();
63 void getResult() const;
64};
65
66struct DXFCPP_EXPORT EventPromiseImpl : PromiseImpl {
67 std::atomic<void *> handle = nullptr;
68 std::atomic<bool> own = true;
69
70 explicit EventPromiseImpl(void *promiseHandle, bool isOwned = true,
71 std::shared_ptr<const PromiseContext> promiseContext = {});
72 ~EventPromiseImpl();
73 std::shared_ptr<EventType> getResult() const;
74};
75
76struct DXFCPP_EXPORT EventsPromiseImpl : PromiseImpl {
77 std::atomic<void *> handle = nullptr;
78 std::atomic<bool> own = true;
79
80 explicit EventsPromiseImpl(void *promiseHandle, bool isOwned = true,
81 std::shared_ptr<const PromiseContext> promiseContext = {});
82 ~EventsPromiseImpl();
83 std::vector<std::shared_ptr<EventType>> getResult() const;
84};
85
86/**
87 * Mixin for wrapping calls to common promise methods.
88 *
89 * @tparam P The promise type
90 */
91template <typename P> struct CommonPromiseMixin {
92 /**
93 * Returns `true` when a computation has completed normally, or exceptionally, or was canceled.
94 *
95 * @return `true` when computation has completed.
96 */
97 bool isDone() const {
98 return static_cast<const P *>(this)->impl.isDone();
99 }
100
101 /**
102 * Returns `true` when computation has completed normally.
103 * Use ::getResult() method to get the result of the computation.
104 * @return `true` when computation has completed normally.
105 * @see ::getResult()
106 */
107 bool hasResult() const {
108 return static_cast<const P *>(this)->impl.hasResult();
109 }
110
111 /**
112 * Returns `true` when a computation has completed exceptionally or was canceled.
113 * Use ::getException() method to get the exceptional outcome of the computation.
114 * @return `true` when computation has completed exceptionally or was canceled.
115 */
116 bool hasException() const {
117 return static_cast<const P *>(this)->impl.hasException();
118 }
119
120 /**
121 * Returns `true` when computation was cancelled.
122 * Use ::getException() method to get the corresponding CancellationException.
123 * @return `true` when computation was cancelled.
124 * @see ::getException()
125 */
126 bool isCancelled() const {
127 return static_cast<const P *>(this)->impl.isCancelled();
128 }
129
130 /**
131 * Returns exceptional outcome of computation. If the computation has no ::hasException() exception,
132 * then this method returns an exception with a message "null". If a computation has completed exceptionally or was
133 * cancelled, then the result of this method is not an exception with a message "null". If computation was @ref
134 * isCancelled() "cancelled", then this method returns "an instance of CancellationException".
135 *
136 * @return exceptional outcome of computation.
137 * @see ::hasException()
138 */
140 return static_cast<const P *>(this)->impl.getException();
141 }
142
143 /**
144 * Wait for computation to complete or timeout or throw an exception in case of exceptional completion.
145 * If the wait is interrupted, then the computation is @ref cancel() "canceled",
146 * the interruption flag on the current thread is set, and "CancellationException" is thrown.
147 *
148 * <p>If the wait times are out, then the computation is @ref cancel() "canceled" and this method returns `false`.
149 * Use this method in the code that shall continue normal execution in case of timeout.
150 *
151 * @param timeoutInMilliseconds The timeout.
152 * @return `true` if the computation has completed normally; `false` when wait timed out.
153 * @throws CancellationException if computation was cancelled.
154 * @throws PromiseException if computation has completed exceptionally.
155 */
156 bool awaitWithoutException(std::int32_t timeoutInMilliseconds) const {
157 return static_cast<const P *>(this)->impl.awaitWithoutException(timeoutInMilliseconds);
158 }
159
160 /**
161 * Wait for computation to complete or timeout or throw an exception in case of exceptional completion.
162 * If the wait is interrupted, then the computation is @ref cancel() "canceled",
163 * the interruption flag on the current thread is set, and "CancellationException" is thrown.
164 *
165 * <p>If the wait times are out, then the computation is @ref cancel() "canceled" and this method returns `false`.
166 * Use this method in the code that shall continue normal execution in case of timeout.
167 *
168 * @param timeoutInMilliseconds The timeout.
169 * @return `true` if the computation has completed normally; `false` when wait timed out.
170 * @throws CancellationException if computation was cancelled.
171 * @throws PromiseException if computation has completed exceptionally.
172 */
173 bool awaitWithoutException(const std::chrono::milliseconds &timeoutInMilliseconds) const {
174 return static_cast<const P *>(this)->impl.awaitWithoutException(
175 dxfcpp::fitToType<std::int32_t>(timeoutInMilliseconds.count()));
176 }
177
178 /**
179 * This method cancels computation. This method does nothing if the computation has already @ref isDone() "completed".
180 *
181 * <p>If cancelled, then ::getException() will return "CancellationException",
182 * @ref isDone() "isDone", @ref isCancelled() "isCancelled", and @ref hasException() "hasException" will
183 * return `true`, all handlers that were installed with `whenDone` method are notified by invoking their
184 * `promiseDone` method, and all waiters on `await` method throw "CancellationException".
185 */
186 void cancel() const {
187 static_cast<const P *>(this)->impl.cancel();
188 }
189};
190
191/**
192 * Mixin for wrapping Promise method calls for a void.
193 *
194 * @tparam P The promise type.
195 */
196template <typename P> struct VoidPromiseMixin {
197 /**
198 * Returns result of computation.
199 *
200 * @see CommonPromiseMixin::hasResult()
201 */
202 void getResult() const {
203 return static_cast<const P *>(this)->impl.getResult();
204 }
205
206 /**
207 * Wait for the computation to complete and return its result or throw an exception in case of exceptional completion.
208 * @throws CancellationException if computation was canceled.
209 * @throws PromiseException if computation has completed exceptionally.
210 */
211 void await() const {
212 static_cast<const P *>(this)->impl.await();
213
214 return getResult();
215 }
216
217 /**
218 * Wait for the computation to complete or timeout and return its result or throw an exception in case of exceptional
219 * completion or timeout.
220 *
221 * @param timeoutInMilliseconds The timeout.
222 * @throws CancellationException if computation was canceled or timed out. On a timeout of a promise returned by
223 * DXFeed, the text of the exception names the request, the waiting time and the state of the endpoint.
224 * @throws PromiseException if computation has completed exceptionally.
225 */
226 void await(std::int32_t timeoutInMilliseconds) const & {
227 static_cast<const P *>(this)->impl.await(timeoutInMilliseconds);
228
229 return getResult();
230 }
231
232 /**
233 * Wait for the computation to complete or timeout and return its result or throw an exception in case of exceptional
234 * completion or timeout.
235 *
236 * @param timeoutInMilliseconds The timeout.
237 * @throws CancellationException if computation was cancelled or timed out. On a timeout of a promise returned by
238 * DXFeed, the text of the exception names the request, the waiting time and the state of the endpoint.
239 * @throws PromiseException if computation has completed exceptionally.
240 */
241 void await(const std::chrono::milliseconds &timeoutInMilliseconds) const & {
242 static_cast<const P *>(this)->impl.await(dxfcpp::fitToType<std::int32_t>(timeoutInMilliseconds.count()));
243
244 return getResult();
245 }
246};
247
248/**
249 * Mixin for wrapping Promise method calls for a single event.
250 * @tparam E The event type.
251 * @tparam P The promise type.
252 */
253template <typename E, typename P> struct EventPromiseMixin {
254 /**
255 * Returns result of computation. If the computation has no @ref CommonPromiseMixin::hasResult() "result", then
256 * this method returns `std::shared_ptr<E>(nullptr)`.
257 *
258 * @return The result of computation.
259 * @see CommonPromiseMixin::hasResult()
260 */
261 std::shared_ptr<E> getResult() const {
262 return convertEvent<EventType, E>(static_cast<const P *>(this)->impl.getResult());
263 }
264
265 /**
266 * Wait for the computation to complete and return its result or throw an exception in case of exceptional completion.
267 * @return result of computation.
268 * @throws CancellationException if computation was canceled.
269 * @throws PromiseException if computation has completed exceptionally.
270 */
271 std::shared_ptr<E> await() const {
272 static_cast<const P *>(this)->impl.await();
273
274 return getResult();
275 }
276
277 /**
278 * Wait for computation to complete or timeout and return its result or throw an exception in case of exceptional
279 * completion or timeout.
280 *
281 * @param timeoutInMilliseconds The timeout.
282 * @return The result of computation.
283 * @throws CancellationException if computation was canceled or timed out. On a timeout of a promise returned by
284 * DXFeed, the text of the exception names the request, the waiting time and the state of the endpoint.
285 * @throws PromiseException if computation has completed exceptionally.
286 */
287 std::shared_ptr<E> await(std::int32_t timeoutInMilliseconds) const & {
288 static_cast<const P *>(this)->impl.await(timeoutInMilliseconds);
289
290 return getResult();
291 }
292
293 /**
294 * Wait for computation to complete or timeout and return its result or throw an exception in case of exceptional
295 * completion or timeout.
296 *
297 * @param timeoutInMilliseconds The timeout.
298 * @return The result of computation.
299 * @throws CancellationException if computation was cancelled or timed out. On a timeout of a promise returned by
300 * DXFeed, the text of the exception names the request, the waiting time and the state of the endpoint.
301 * @throws PromiseException if computation has completed exceptionally.
302 */
303 std::shared_ptr<E> await(const std::chrono::milliseconds &timeoutInMilliseconds) const & {
304 static_cast<const P *>(this)->impl.await(dxfcpp::fitToType<std::int32_t>(timeoutInMilliseconds.count()));
305
306 return getResult();
307 }
308};
309
310template <typename E, typename P> struct EventsPromiseMixin {
311 /**
312 * Returns result of computation. If computation has no @ref CommonPromiseMixin::hasResult() "result", then
313 * this method returns an empty collection.
314 *
315 * @return The result of computation.
316 * @see CommonPromiseMixin::hasResult()
317 */
318 std::vector<std::shared_ptr<E>> getResult() const {
319 return convertEvents<EventType, E>(static_cast<const P *>(this)->impl.getResult());
320 }
321
322 /**
323 * Wait for computation to complete and return its result or throw an exception in case of exceptional completion.
324 * @return result of computation.
325 * @throws CancellationException if computation was cancelled.
326 * @throws PromiseException if computation has completed exceptionally.
327 */
328 std::vector<std::shared_ptr<E>> await() const {
329 static_cast<const P *>(this)->impl.await();
330
331 return getResult();
332 }
333
334 /**
335 * Wait for computation to complete or timeout and return its result or throw an exception in case of exceptional
336 * completion or timeout.
337 *
338 * @param timeoutInMilliseconds The timeout.
339 * @return The result of computation.
340 * @throws CancellationException if computation was cancelled or timed out. On a timeout of a promise returned by
341 * DXFeed, the text of the exception names the request, the waiting time and the state of the endpoint.
342 * @throws PromiseException if computation has completed exceptionally.
343 */
344 std::vector<std::shared_ptr<E>> await(std::int32_t timeoutInMilliseconds) const & {
345 static_cast<const P *>(this)->impl.await(timeoutInMilliseconds);
346
347 return getResult();
348 }
349
350 /**
351 * Wait for computation to complete or timeout and return its result or throw an exception in case of exceptional
352 * completion or timeout.
353 *
354 * @param timeoutInMilliseconds The timeout.
355 * @return The result of computation.
356 * @throws CancellationException if computation was cancelled or timed out. On a timeout of a promise returned by
357 * DXFeed, the text of the exception names the request, the waiting time and the state of the endpoint.
358 * @throws PromiseException if computation has completed exceptionally.
359 */
360 std::vector<std::shared_ptr<E>> await(const std::chrono::milliseconds &timeoutInMilliseconds) const & {
361 static_cast<const P *>(this)->impl.await(dxfcpp::fitToType<std::int32_t>(timeoutInMilliseconds.count()));
362
363 return getResult();
364 }
365};
366
367/**
368 * Result of a computation that will be completed normally or exceptionally in the future.
369 * @tparam T The result type.
370 */
371template <typename T> struct Promise {};
372
373/**
374 * Result of an void receiving that will be completed normally or exceptionally in the future.
375 */
376template <> struct Promise<void> : CommonPromiseMixin<Promise<void>>, VoidPromiseMixin<Promise<void>> {
377 friend struct CommonPromiseMixin<Promise>;
378 friend struct VoidPromiseMixin<Promise>;
379 friend struct Promises;
380
381 private:
382 VoidPromiseImpl impl;
383
384 public:
385 explicit Promise(void *handle, bool own = true, std::shared_ptr<const PromiseContext> context = {})
386 : impl(handle, own, std::move(context)) {
387 }
388
389 Promise(const Promise &) = delete;
390 Promise &operator=(const Promise &) = delete;
391
392 Promise(Promise && other) noexcept : impl(other.impl.handle, other.impl.own, other.impl.context) {
393 other.impl.handle = nullptr;
394 other.impl.own = false;
395 }
396
397 Promise &operator=(Promise &&) noexcept = delete;
398};
399
400/**
401 * Result of an event receiving that will be completed normally or exceptionally in the future.
402 * @tparam E The event type.
403 */
404template <typename E>
405struct Promise<std::shared_ptr<E>> : CommonPromiseMixin<Promise<std::shared_ptr<E>>>,
406 EventPromiseMixin<E, Promise<std::shared_ptr<E>>> {
407 friend struct CommonPromiseMixin<Promise>;
408 friend struct EventPromiseMixin<E, Promise>;
409 friend struct Promises;
410
411 private:
412 EventPromiseImpl impl;
413
414 public:
415 explicit Promise(void *handle, bool own = true, std::shared_ptr<const PromiseContext> context = {})
416 : impl(handle, own, std::move(context)) {
417 }
418
419 template <Derived<E> D>
420 explicit Promise(std::shared_ptr<Promise<std::shared_ptr<D>>> other) : impl(other->impl->handle, false) {
421 }
422
423 template <BaseOf<E> B> std::shared_ptr<Promise<std::shared_ptr<B>>> sharedAs(bool transferOwnership = false) {
424 if (transferOwnership) {
425 impl.own = false;
426 }
427
428 return std::make_shared<Promise<std::shared_ptr<B>>>(impl.handle, transferOwnership, impl.context);
429 }
430
431 Promise(const Promise &) = delete;
432 Promise &operator=(const Promise &) = delete;
433
434 Promise(Promise && other) noexcept : impl(other.impl.handle, other.impl.own, other.impl.context) {
435 other.impl.handle = nullptr;
436 other.impl.own = false;
437 }
438
439 Promise &operator=(Promise &&) noexcept = delete;
440};
441
442struct DXFCPP_EXPORT PromiseListImpl {
443 std::atomic<void *> handle = nullptr;
444
445 explicit PromiseListImpl(void *promiseListHandle);
446 ~PromiseListImpl();
447
448 static std::size_t getSize(void *handle);
449 static void *getElement(void *handle, std::size_t index);
450};
451
452/**
453 * A list of event receiving results that will be completed normally or exceptionally in the future.
454 * It is a std::vector<Promise<std::shared_ptr<E>>> wrapper with Graal semantics.
455 * @tparam E The event type.
456 */
457template <typename E> struct PromiseList {
458 friend struct Promises;
459
461
463
464 using value_type = typename data_type::value_type;
465 using allocator_type = typename data_type::allocator_type;
466 using pointer = typename data_type::pointer;
467 using const_pointer = typename data_type::const_pointer;
468 using reference = typename data_type::reference;
469 using const_reference = typename data_type::const_reference;
470 using size_type = typename data_type::size_type;
471 using difference_type = typename data_type::difference_type;
472
473 using iterator = typename data_type::iterator;
474 using const_iterator = typename data_type::const_iterator;
477
478 private:
479 PromiseListImpl impl;
480
481 data_type data_;
482
483 public:
484 explicit PromiseList(void *handle = nullptr) : impl(handle) {
485 }
486
487 /**
488 * Creates the list of promises from the native list.
489 *
490 * @param handle The native list.
491 * @param contexts The descriptions of the requests, indexed by the element index of the native list (a null
492 * element of the native list is skipped, its description too). May be empty or shorter than the list.
493 */
494 static std::shared_ptr<PromiseList>
495 create(void *handle, const std::vector<std::shared_ptr<const PromiseContext>> &contexts = {}) {
496 if (!handle) {
497 return {};
498 }
499
500 std::vector<Promise<std::shared_ptr<E>>> result{};
501 auto size = PromiseListImpl::getSize(handle);
502 auto promiseList = std::make_shared<PromiseList<E>>(handle);
503
504 promiseList->data_.reserve(size);
505
506 for (std::size_t elementIndex = 0; elementIndex < size; elementIndex++) {
507 if (auto element = PromiseListImpl::getElement(handle, elementIndex)) {
508 promiseList->data_.emplace_back(element, false,
509 elementIndex < contexts.size() ? contexts[elementIndex] : nullptr);
510 }
511 }
512
513 return promiseList;
514 }
515
516 pointer data() noexcept {
517 return data_.data();
518 }
519
520 const_pointer data() const noexcept {
521 return data_.data();
522 }
523
524 iterator begin() noexcept {
525 return data_.begin();
526 }
527
528 const_iterator begin() const noexcept {
529 return data_.begin();
530 }
531
532 iterator end() noexcept {
533 return data_.end();
534 }
535
536 const_iterator end() const noexcept {
537 return data_.end();
538 }
539
540 const_iterator cbegin() const noexcept {
541 return data_.cbegin();
542 }
543
544 const_iterator cend() const noexcept {
545 return data_.cend();
546 }
547
548 reverse_iterator rbegin() noexcept {
549 return data_.rbegin();
550 }
551
552 reverse_iterator rend() noexcept {
553 return data_.rend();
554 }
555
556 const_reverse_iterator crbegin() const noexcept {
557 return data_.crbegin();
558 }
559
560 const_reverse_iterator crend() const noexcept {
561 return data_.crend();
562 }
563
564 bool empty() const noexcept {
565 return data_.empty();
566 }
567
568 size_type size() const noexcept {
569 return data_.size();
570 }
571
572 size_type max_size() const noexcept {
573 return data_.max_size();
574 }
575
576 size_type capacity() const noexcept {
577 return data_.capacity();
578 }
579
580 reference operator[](const size_type pos) noexcept {
581 return data_[pos];
582 }
583
584 const_reference operator[](const size_type pos) const noexcept {
585 return data_[pos];
586 }
587
588 reference at(const size_type pos) {
589 return data_.at(pos);
590 }
591
592 const_reference at(const size_type pos) const {
593 return data_.at(pos);
594 }
595
596 reference front() noexcept {
597 return data_.front();
598 }
599
600 const_reference front() const noexcept {
601 return data_.front();
602 }
603
604 reference back() noexcept {
605 return data_.back();
606 }
607
608 const_reference back() const noexcept {
609 return data_.back();
610 }
611};
612
613/**
614 * Result of an collection of events receiving that will be completed normally or exceptionally in the future.
615 * @tparam E The event type.
616 */
617template <typename E>
620 friend struct CommonPromiseMixin<Promise>;
621 friend struct EventsPromiseMixin<E, Promise>;
622 friend struct Promises;
623
624 private:
626
627 public:
628 explicit Promise(void *handle, bool own = true, std::shared_ptr<const PromiseContext> context = {})
629 : impl(handle, own, std::move(context)) {
630 }
631
632 Promise(const Promise &) = delete;
633 Promise &operator=(const Promise &) = delete;
634
636 other.impl.handle = nullptr;
637 other.impl.own = false;
638 }
639
640 Promise &operator=(Promise &&) noexcept = delete;
641};
642
643DXFCPP_END_NAMESPACE
644
645/// @}
646
647DXFCXX_DISABLE_MSC_WARNINGS_POP()
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_name(dxfc_dxendpoint_builder_t builderHandle, const char *name)
Changes the name used to distinguish multiple endpoints in the same process (GraalVM Isolate) in logs...
Definition DXEndpoint.cpp:1125
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_properties(dxfc_dxendpoint_builder_t builder, const dxfc_dxendpoint_property_t **properties, size_t size)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.cpp:1168
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:1451
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher)
Definition DXEndpoint.cpp:1652
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_supports_property(dxfc_dxendpoint_builder_t builder, const char *key, DXFC_OUT int *supports)
Checks if a property is supported.
Definition DXEndpoint.cpp:1200
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_add_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Adds a listener notified about changes in state property.
Definition DXEndpoint.cpp:1598
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections.
Definition DXEndpoint.cpp:1513
#define DXFCPP_EXPORT
Definition api.h:35
void * dxfc_dxendpoint_builder_t
The dxFeed endpoint's builder handle.
Definition api.h:219
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close_and_await_termination(dxfc_dxendpoint_t endpoint)
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:1395
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_not_connected(dxfc_dxendpoint_t endpoint)
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:1564
void(*) dxfc_dxendpoint_state_change_listener(dxfc_dxendpoint_state_t old_state, dxfc_dxendpoint_state_t new_state, void *user_data)
The endpoint current state change listener.
Definition api.h:190
dxfc_dxendpoint_state_t
Represents the current state of endpoint.
Definition api.h:161
@ DXFC_DXENDPOINT_STATE_CLOSED
Endpoint was closed.
Definition api.h:181
@ DXFC_DXENDPOINT_STATE_NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition api.h:165
@ DXFC_DXENDPOINT_STATE_CONNECTING
The connect function was called to establish connection to remove endpoint, but the connection is not...
Definition api.h:171
@ DXFC_DXENDPOINT_STATE_CONNECTED
The connection to the remote endpoint is established.
Definition api.h:176
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of dxFeed endpoint with a FEED role.
Definition DXEndpoint.cpp:1264
#define DXFC_OUT
Definition api.h:17
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_state(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_state_t *state)
Returns the state of this endpoint.
Definition DXEndpoint.cpp:1581
void * dxfc_dxendpoint_t
The dxFeed endpoint handle.
Definition api.h:210
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_property(dxfc_dxendpoint_builder_t builder, const char *key, const char *value)
Sets the specified property.
Definition DXEndpoint.cpp:1146
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder)
Removes a builder from the registry.
Definition DXEndpoint.cpp:1252
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_connect(dxfc_dxendpoint_t endpoint, const char *address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:1473
dxfc_error_code_t
List of error codes.
Definition api.h:61
@ DXFC_EC_ERROR
The error returned if the current operation cannot be completed.
Definition api.h:72
@ DXFC_EC_SUCCESS
OK.
Definition api.h:65
@ DXFC_EC_G_ERR
dxFeed Graal Native API error.
Definition api.h:69
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_remove_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:1624
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_set_property(const char *key, const char *value)
Sets the system property indicated by the specified key.
Definition System.cpp:208
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_build(dxfc_dxendpoint_builder_t builder, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Builds the new dxFeed endpoint instance.
Definition DXEndpoint.cpp:1222
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed)
Definition DXEndpoint.cpp:1647
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_processed(dxfc_dxendpoint_t endpoint)
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:1547
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint)
Closes this endpoint.
Definition DXEndpoint.cpp:1378
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_new_builder(DXFC_OUT dxfc_dxendpoint_builder_t *builder)
Creates a new dxFeed endpoint's builder instance.
Definition DXEndpoint.cpp:1087
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_reconnect(dxfc_dxendpoint_t endpoint)
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:1496
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_role(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_role_t *role)
Returns the role of this endpoint.
Definition DXEndpoint.cpp:1412
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:1429
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_get_property(const char *key, DXFC_OUT char *buffer, size_t buffer_size)
Gets the system property indicated by the specified key.
dxfc_dxendpoint_role_t
Represents the role of an endpoint that was specified during its creation.
Definition api.h:101
@ DXFC_DXENDPOINT_ROLE_PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition api.h:139
@ DXFC_DXENDPOINT_ROLE_STREAM_FEED
STREAM_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED and also connects to the remote data fee...
Definition api.h:128
@ DXFC_DXENDPOINT_ROLE_FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition api.h:111
@ DXFC_DXENDPOINT_ROLE_STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXFC_DXENDPOINT_ROLE_PUBLISHER and also connects to the remot...
Definition api.h:148
@ DXFC_DXENDPOINT_ROLE_LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition api.h:155
@ DXFC_DXENDPOINT_ROLE_ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED, but it is designed to be used with d...
Definition api.h:119
void * dxfc_dxpublisher_t
The dxFeed publisher handle.
Definition api.h:229
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:1321
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:1292
void * dxfc_dxfeed_t
The dxFeed handle.
Definition api.h:224
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_role(dxfc_dxendpoint_builder_t builder, dxfc_dxendpoint_role_t role)
Sets role for the created dxFeed endpoint.
Definition DXEndpoint.cpp:1108
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:1349
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint)
Removes the dxFeed endpoint from the registry.
Definition DXEndpoint.cpp:1657
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect_and_clear(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:1530
T & operator*() const noexcept
Definition AutoClose.hpp:173
AutoClose() noexcept=default
Creates an empty AutoClose.
AutoClose(std::shared_ptr< T > entity) noexcept
Creates an AutoClose that closes the entity.
Definition AutoClose.hpp:119
~AutoClose() noexcept
Closes the entity.
Definition AutoClose.hpp:140
const std::shared_ptr< T > & get() const noexcept
Definition AutoClose.hpp:163
std::shared_ptr< T > release() noexcept
Makes this AutoClose empty without closing the entity.
Definition AutoClose.hpp:158
AutoClose & operator=(AutoClose &&other) noexcept
Closes the current entity and takes the entity of the other AutoClose, which becomes empty.
Definition AutoClose.hpp:130
operator bool() const noexcept
Definition AutoClose.hpp:178
AutoClose(AutoClose &&other) noexcept
Takes the entity of the other AutoClose, which becomes empty.
Definition AutoClose.hpp:126
T * operator->() const noexcept
Definition AutoClose.hpp:168
void reset() noexcept
Closes the entity now and makes this AutoClose empty.
Definition AutoClose.hpp:145
Builder class for DXEndpoint that supports additional configuration properties.
Definition DXEndpoint.hpp:1069
std::shared_ptr< DXEndpoint > build()
Builds DXEndpoint instance.
Definition DXEndpoint.cpp:695
std::shared_ptr< Builder > withExecutor(const std::shared_ptr< Executor > &executor)
Sets the executor that is used for notifications (events, state changes, etc.) of the endpoint to bui...
Definition DXEndpoint.hpp:1194
std::shared_ptr< Builder > withProperties(Properties &&properties)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.hpp:1160
~Builder() noexcept override
Releases the GraalVM handle.
Definition DXEndpoint.cpp:733
std::shared_ptr< Builder > withRole(Role role)
Sets role for the created DXEndpoint.
Definition DXEndpoint.cpp:647
Subscription for a set of symbols and event types.
Definition DXFeedSubscription.hpp:102
Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols an...
Definition DXFeedSubscription.hpp:953
The enumeration type that provides additional information about the dxFeed Graal C++-API event type.
Definition EventTypeEnum.hpp:40
Source identifier for IndexedEvent.
Definition IndexedEventSource.hpp:31
Mixin for wrapping calls to common promise methods.
Definition Promise.hpp:91
JavaException getException() const
Returns exceptional outcome of computation.
Definition Promise.hpp:139
void cancel() const
This method cancels computation.
Definition Promise.hpp:186
bool hasResult() const
Returns true when computation has completed normally.
Definition Promise.hpp:107
bool isCancelled() const
Returns true when computation was cancelled.
Definition Promise.hpp:126
bool hasException() const
Returns true when a computation has completed exceptionally or was canceled.
Definition Promise.hpp:116
bool awaitWithoutException(const std::chrono::milliseconds &timeoutInMilliseconds) const
Wait for computation to complete or timeout or throw an exception in case of exceptional completion.
Definition Promise.hpp:173
bool isDone() const
Returns true when a computation has completed normally, or exceptionally, or was canceled.
Definition Promise.hpp:97
bool awaitWithoutException(std::int32_t timeoutInMilliseconds) const
Wait for computation to complete or timeout or throw an exception in case of exceptional completion.
Definition Promise.hpp:156
Manages network connections to feed or publisher.
Definition DXEndpoint.hpp:189
void removeMessageConnectorListener(std::size_t listenerId) noexcept
Removes a listener added with DXEndpoint::addMessageConnectorListener().
Definition DXEndpoint.cpp:946
bool isClosed() const
Definition DXEndpoint.cpp:901
SimpleHandler< void(DXEndpoint::State, DXEndpoint::State)> & onStateChange() noexcept
Returns the onStateChange handler that can be used to add or remove listeners.
Definition DXEndpoint.cpp:918
static std::shared_ptr< DXEndpoint > create(Role role)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:888
void setRequestedAggregationPeriod(const TimePeriod &requestedAggregationPeriod) const
Sets the aggregation period that this endpoint requests from the server.
Definition DXEndpoint.cpp:568
static constexpr char DXFEED_AGGREGATION_PERIOD_PROPERTY[]
"dxfeed.aggregationPeriod"
Definition DXEndpoint.hpp:279
static constexpr char DXENDPOINT_EVENT_TIME_PROPERTY[]
"dxendpoint.eventTime"
Definition DXEndpoint.hpp:366
void setRequestedAggregationPeriod(std::chrono::milliseconds requestedAggregationPeriod) const
Sets the aggregation period that this endpoint requests from the server.
Definition DXEndpoint.cpp:573
static constexpr char NAME_PROPERTY[]
"name"
Definition DXEndpoint.hpp:206
static constexpr char DXFEED_PASSWORD_PROPERTY[]
"dxfeed.password"
Definition DXEndpoint.hpp:260
std::shared_ptr< DXFeed > getFeed() const
Definition DXEndpoint.cpp:528
static constexpr char DXSCHEME_NANO_TIME_PROPERTY[]
"dxscheme.nanoTime"
Definition DXEndpoint.hpp:399
State
Represents the current state of endpoint.
Definition DXEndpoint.hpp:491
@ CLOSED
Endpoint was closed.
Definition DXEndpoint.hpp:511
@ CONNECTING
The connect method was called to establish connection to remove endpoint, but the connection is not e...
Definition DXEndpoint.hpp:501
@ CONNECTED
The connection to the remote endpoint is established.
Definition DXEndpoint.hpp:506
@ NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition DXEndpoint.hpp:495
static constexpr char DXFEED_THREAD_POOL_SIZE_PROPERTY[]
"dxfeed.threadPoolSize"
Definition DXEndpoint.hpp:269
TimePeriodInfo getAggregationPeriodInfo() const
Returns the aggregation period that the servers report, over all connections of this endpoint.
Definition DXEndpoint.cpp:586
static constexpr char DXPUBLISHER_THREAD_POOL_SIZE_PROPERTY[]
"dxpublisher.threadPoolSize"
Definition DXEndpoint.hpp:349
void reconnect() const
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:473
std::shared_ptr< DXEndpoint > Ptr
The alias to a type of shared pointer to the DXEndpoint object.
Definition DXEndpoint.hpp:191
static std::shared_ptr< DXEndpoint > create()
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:879
void removeStateChangeListener(std::size_t listenerId) noexcept
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:909
const std::string & getName() const &noexcept
Definition DXEndpoint.cpp:905
Role
Represents the role of an endpoint that was specified during its creation.
Definition DXEndpoint.hpp:420
@ PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition DXEndpoint.hpp:465
@ STREAM_FEED
STREAM_FEED endpoint is similar to DXEndpoint::FEED and also connects to the remote data feed provide...
Definition DXEndpoint.hpp:453
@ LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition DXEndpoint.hpp:481
@ ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXEndpoint::FEED, but it is designed to be used with OnDemandSe...
Definition DXEndpoint.hpp:444
@ STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXEndpoint::PUBLISHER and also connects to the remote publish...
Definition DXEndpoint.hpp:474
@ FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition DXEndpoint.hpp:431
std::string toString() const override
Returns a string representation of the current object.
Definition DXEndpoint.cpp:754
void awaitProcessed() const
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:509
std::shared_ptr< DXPublisher > getPublisher() const
Definition DXEndpoint.cpp:537
static constexpr char DXFEED_PROPERTIES_PROPERTY[]
"dxfeed.properties"
Definition DXEndpoint.hpp:221
std::optional< TimePeriod > getRequestedAggregationPeriod() const
Returns the aggregation period that this endpoint requests from the server, or an empty value if no p...
Definition DXEndpoint.cpp:556
static constexpr char DXSCHEME_ENABLED_PROPERTY_PREFIX[]
"dxscheme.enabled."
Definition DXEndpoint.hpp:413
State getState() const
Returns the state of this endpoint.
Definition DXEndpoint.cpp:433
static constexpr char DXPUBLISHER_ADDRESS_PROPERTY[]
"dxpublisher.address"
Definition DXEndpoint.hpp:340
std::vector< MessageConnectorInfo > getConnectors() const
Returns the snapshots of the message connectors of this endpoint: one for each address it connects to...
Definition DXEndpoint.cpp:926
void awaitNotConnected() const
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:500
static constexpr char DXFEED_STRIPE_PROPERTY[]
"dxfeed.stripe"
Definition DXEndpoint.hpp:296
static std::shared_ptr< DXEndpoint > getInstance(Role role)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:861
void close() const
Closes this endpoint.
Definition DXEndpoint.cpp:956
static constexpr char DXFEED_REQUESTED_AGGREGATION_PERIOD_PROPERTY[]
"dxfeed.requestedAggregationPeriod"
Definition DXEndpoint.hpp:321
void setRequestedAggregationPeriod(std::int64_t requestedAggregationPeriod) const
Sets the aggregation period that this endpoint requests from the server.
Definition DXEndpoint.cpp:577
void disconnect() const
Terminates all remote network connections.
Definition DXEndpoint.cpp:482
void closeAndAwaitTermination() const
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:518
static std::shared_ptr< DXEndpoint > getInstance()
Returns a default application-wide singleton instance of DXEndpoint with a FEED role.
Definition DXEndpoint.cpp:852
static constexpr char DXPUBLISHER_PROPERTIES_PROPERTY[]
"dxpublisher.properties"
Definition DXEndpoint.hpp:330
static constexpr char DXFEED_WILDCARD_ENABLE_PROPERTY[]
"dxfeed.wildcard.enable"
Definition DXEndpoint.hpp:288
static constexpr char DXFEED_ADDRESS_PROPERTY[]
"dxfeed.address"
Definition DXEndpoint.hpp:240
static constexpr char DXFEED_STICKY_SUBSCRIPTION_PROPERTY[]
"dxfeed.stickySubscriptionPeriod"
Definition DXEndpoint.hpp:304
static constexpr char DXFEED_USER_PROPERTY[]
"dxfeed.user"
Definition DXEndpoint.hpp:250
void disconnectAndClear() const
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:491
Role getRole() const noexcept
Returns the role of this endpoint.
Definition DXEndpoint.cpp:897
std::optional< ConnectionError > getLastConnectionError() const
Returns the last connection error of this endpoint: the newest failed connect attempt or dropped conn...
Definition DXEndpoint.cpp:922
static constexpr char DXENDPOINT_STORE_EVERYTHING_PROPERTY[]
"dxendpoint.storeEverything"
Definition DXEndpoint.hpp:379
static std::shared_ptr< Builder > newBuilder()
Creates a new Builder instance.
Definition DXEndpoint.cpp:870
Main entry class for dxFeed API (read it first).
Definition DXFeed.hpp:142
void detachSubscriptionAndClear(const std::shared_ptr< DXFeedSubscription > &subscription) const
Detaches the given subscription from this feed and clears data delivered to this subscription by publ...
Definition DXFeed.cpp:102
Collection getLastEvents(Collection &&events)
Returns the last events for the specified list of event instances.
Definition DXFeed.hpp:330
std::shared_ptr< PromiseList< E > > getLastEventsPromises(std::initializer_list< SymbolWrapper > collection) const
Requests the last events for the specified event type and a collection of symbols.
Definition DXFeed.hpp:778
std::vector< std::shared_ptr< E > > getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::chrono::milliseconds fromTime, std::chrono::milliseconds toTime) const
Returns time series of events for the specified event type, symbol and a range of time if there is a ...
Definition DXFeed.hpp:1056
std::shared_ptr< DXFeedSubscription > createSubscription(const EventTypeEnum &eventType) const
Creates a new subscription for a single event type that is attached to this feed.
Definition DXFeed.cpp:167
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(std::initializer_list< EventTypeEnum > eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.cpp:214
std::shared_ptr< DXFeedSubscription > createSubscription(EventTypeIt begin, EventTypeIt end) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:424
std::shared_ptr< PromiseList< E > > getLastEventsPromises(const SymbolsCollection &collection) const
Requests the last events for the specified event type and a collection of symbols.
Definition DXFeed.hpp:729
std::shared_ptr< E > getLastEventIfSubscribed(const SymbolWrapper &symbol)
Returns the last event for the specified event type and symbol if there is a subscription for it.
Definition DXFeed.hpp:364
std::shared_ptr< DXFeedSubscription > createSubscription(std::initializer_list< EventTypeEnum > eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.cpp:180
std::vector< std::shared_ptr< E > > getTimeSeriesIfSubscribed(const SymbolWrapper &symbol, std::chrono::milliseconds fromTime) const
Returns time series of events for the specified event type, symbol and a range of time (without an up...
Definition DXFeed.hpp:1087
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(EventTypeIt begin, EventTypeIt end) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:523
static std::shared_ptr< DXFeed > getInstance()
Returns a default application-wide singleton instance of feed.
Definition DXFeed.cpp:25
std::shared_ptr< E > getLastEvent(std::shared_ptr< E > event)
Returns the last event for the specified event instance.
Definition DXFeed.hpp:306
std::shared_ptr< PromiseList< E > > getLastEventsPromises(SymbolIt begin, SymbolIt end) const
Requests the last events for the specified event type and a collection of symbols.
Definition DXFeed.hpp:670
std::shared_ptr< DXFeedSubscription > createSubscription(const EventTypesCollection &eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:469
std::shared_ptr< Promise< std::shared_ptr< E > > > getLastEventPromise(const SymbolWrapper &symbol) const
Requests the last event for the specified event type and symbol.
Definition DXFeed.hpp:616
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(const EventTypesCollection &eventTypes) const
Creates new subscription for multiple event types that is attached to this feed.
Definition DXFeed.hpp:582
std::string toString() const override
Returns a string representation of the current object.
Definition DXFeed.cpp:359
std::shared_ptr< DXFeed > Ptr
The alias to a type of shared pointer to the DXFeed object.
Definition DXFeed.hpp:144
std::shared_ptr< Promise< std::vector< std::shared_ptr< E > > > > getIndexedEventsPromise(const SymbolWrapper &symbol, const IndexedEventSource &source) const
Requests a container of indexed events for the specified event type, symbol and source.
Definition DXFeed.hpp:834
void detachSubscription(const std::shared_ptr< DXFeedSubscription > &subscription) const
Detaches the given subscription from this feed.
Definition DXFeed.cpp:76
std::vector< std::shared_ptr< E > > getIndexedEventsIfSubscribed(const SymbolWrapper &symbol, const IndexedEventSource &source) const
Returns a vector of indexed events for the specified event type, symbol and source if there is a subs...
Definition DXFeed.hpp:892
void attachSubscription(const std::shared_ptr< DXFeedSubscription > &subscription) const
Attaches the given subscription to this feed.
Definition DXFeed.cpp:34
std::shared_ptr< DXFeedTimeSeriesSubscription > createTimeSeriesSubscription(const EventTypeEnum &eventType) const
Creates a new subscription for a single event type that is attached to this feed.
Definition DXFeed.cpp:195
Provides API for publishing of events to local or remote DXFeed.
Definition DXPublisher.hpp:62
Mixin for wrapping Promise method calls for a single event.
Definition Promise.hpp:253
std::shared_ptr< E > getResult() const
Returns result of computation.
Definition Promise.hpp:261
std::shared_ptr< E > await() const
Wait for the computation to complete and return its result or throw an exception in case of exception...
Definition Promise.hpp:271
std::shared_ptr< E > await(const std::chrono::milliseconds &timeoutInMilliseconds) const &
Wait for computation to complete or timeout and return its result or throw an exception in case of ex...
Definition Promise.hpp:303
std::shared_ptr< E > await(std::int32_t timeoutInMilliseconds) const &
Wait for computation to complete or timeout and return its result or throw an exception in case of ex...
Definition Promise.hpp:287
Concrete implementation of a event for std::string.
Definition EventType.hpp:148
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:42
std::string toString() const override
Returns a string representation of the current object.
Definition api.cpp:57
virtual std::int64_t getEventTime() const noexcept
Returns time when an event was created or zero when time is not available.
Definition api.cpp:44
virtual void assign(std::shared_ptr< EventType > event)
Replaces the contents of the event.
Definition api.cpp:53
virtual void setEventTime(std::int64_t eventTime) noexcept
Changes event creation time.
Definition api.cpp:48
The part of IndexedEventTxModel that does not depend on the type of events.
Definition IndexedEventTxModel.hpp:48
Thrown to indicate that a method has been passed an illegal or inappropriate argument.
Definition InvalidArgumentException.hpp:23
A wrapper over the interceptable Java exceptions thrown by the dxFeed Native Graal SDK.
Definition JavaException.hpp:26
Represents up-to-date information about some condition or state of an external entity that updates in...
Definition LastingEvent.hpp:33
std::shared_ptr< LastingEvent > Ptr
The alias to a type of shared pointer to the LastingEvent object.
Definition LastingEvent.hpp:35
static bool isActive() noexcept
Provides on-demand historical tick data replay controls.
Definition OnDemandService.hpp:77
The raw description of the request that created a promise of DXFeed.
Definition PromiseContext.hpp:24
A list of event receiving results that will be completed normally or exceptionally in the future.
Definition Promise.hpp:457
static std::shared_ptr< PromiseList > create(void *handle, const std::vector< std::shared_ptr< const PromiseContext > > &contexts={})
Creates the list of promises from the native list.
Definition Promise.hpp:495
Result of an event receiving that will be completed normally or exceptionally in the future.
Definition Promise.hpp:406
Result of an void receiving that will be completed normally or exceptionally in the future.
Definition Promise.hpp:376
Result of a computation that will be completed normally or exceptionally in the future.
Definition Promise.hpp:371
A class that represents a promise-based implementation often used for handling asynchronous operation...
Definition Promises.hpp:46
A helper class needed to construct smart pointers to objects and does not allow explicit construction...
Definition SharedEntity.hpp:80
static auto createShared(Args &&...args)
Creates a smart pointer to an object.
Definition SharedEntity.hpp:95
A base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:25
virtual std::string toString() const
Returns a string representation of the current object.
Definition SharedEntity.hpp:69
std::shared_ptr< T > sharedAs() const noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T or std::shared_ptr<T>{nu...
Definition SharedEntity.hpp:60
std::shared_ptr< T > sharedAs() noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T or std::shared_ptr<T>{nu...
Definition SharedEntity.hpp:49
std::shared_ptr< SharedEntity > Ptr
The alias to a type of shared pointer to the SharedEntity object.
Definition SharedEntity.hpp:27
bool is() const noexcept
Checks that the object is of type T: its dynamic type is T or derived from T.
Definition SharedEntity.hpp:38
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:309
SimpleHandler(const char *component) noexcept
Creates the new handler.
Definition Handler.hpp:197
void removeAll()
Removes all the listeners.
Definition Handler.hpp:352
SimpleHandler() noexcept=default
Creates the new handler.
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:381
void operator()(ArgTypes... args) noexcept
Calls the listeners on the current thread and passes the args to them.
Definition Handler.hpp:254
void handle(ArgTypes... args) noexcept
Calls the listeners on the current thread and passes the args to them.
Definition Handler.hpp:229
A thread-safe list of listeners with a given signature.
Definition Handler.hpp:63
Immutable value class for a range of time periods: the minimum and the maximum period in milliseconds...
Definition TimePeriodInfo.hpp:30
constexpr std::int64_t getMax() const noexcept
Returns the maximum period in milliseconds.
Definition TimePeriodInfo.hpp:63
static const TimePeriodInfo EMPTY
The value meaning "known to be zero". It has zero minimum and maximum.
Definition TimePeriodInfo.hpp:17
constexpr bool isUnknown() const noexcept
Definition TimePeriodInfo.hpp:70
std::string toString() const
Returns the info as JSON with the periods in seconds, as Java does: {"min":1.5,"max":2}...
Definition TimePeriodInfo.cpp:103
static const TimePeriodInfo UNKNOWN
The value meaning "not set / unknown". It has negative minimum and maximum.
Definition TimePeriodInfo.hpp:16
constexpr std::int64_t getMin() const noexcept
Returns the minimum period in milliseconds.
Definition TimePeriodInfo.hpp:53
Value class for a period of time with support for ISO8601 duration format.
Definition TimePeriod.hpp:29
static const TimePeriod UNLIMITED
Time-period of "infinity" (time of std::numeric_limits<std::int64_t>::max() or LLONG_MAX).
Definition TimePeriod.hpp:15
static TimePeriod valueOf(std::chrono::milliseconds value)
Returns TimePeriod with value milliseconds.
Definition TimePeriod.cpp:21
std::int64_t getNanos() const
Returns value in nanoseconds.
Definition TimePeriod.cpp:37
static const TimePeriod ZERO
Time-period of zero.
Definition TimePeriod.hpp:14
std::int32_t getSeconds() const
Returns value in seconds.
Definition TimePeriod.cpp:33
std::int64_t getTime() const
Returns value in milliseconds.
Definition TimePeriod.cpp:29
TimePeriod(ConstructionKey, JavaObjectHandle< TimePeriod > &&handle)
Not a part of the API: it lets std::optional<TimePeriod> create the value in place (TimePeriod can no...
Definition TimePeriod.cpp:44
Mixin for wrapping Promise method calls for a void.
Definition Promise.hpp:196
void await(std::int32_t timeoutInMilliseconds) const &
Wait for the computation to complete or timeout and return its result or throw an exception in case o...
Definition Promise.hpp:226
void await(const std::chrono::milliseconds &timeoutInMilliseconds) const &
Wait for the computation to complete or timeout and return its result or throw an exception in case o...
Definition Promise.hpp:241
void await() const
Wait for the computation to complete and return its result or throw an exception in case of exception...
Definition Promise.hpp:211
void getResult() const
Returns result of computation.
Definition Promise.hpp:202
Whether T is std::shared_ptr<E>, where E is a descendant of LastingEvent (the elements of DXFeed::get...
Definition DXFeed.hpp:39
The simple key-value structure that represents an endpoint's property.
Definition api.h:196
const char * key
The property's key.
Definition api.h:198
const char * value
The property's value.
Definition api.h:200