-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Architectural changes to use boost thread_pool, boost::future, std::promise, std::nested_exception, connection local invocation and event handler maps #584
Conversation
Changed the ResponseThread to ResponseProcessor and it now processes the response message directly by default and will use a thread_pool if the newly introduced parameter `hazelcast.client.response.executor.thread.count` is set to a positive value. Removed custom Thread, Future implementations and used std::thread, boost::asio::thread_pool and boost::future/boost::promise. boost::future supports continuation (`.then` support). Changed the invocation and event handler map design. Using an `unordered_map` which which only being accessed from the same `io` thread for the connection. This eliminated the need for using sync maps for invocations and events. If any other thread needs to access the invocations, it passes this request to io thread. This is only needed when closing the socket for notifying the outstanding invocations. If an invocation can not be queued into the connection (i.e. no connection exists for the invocation and it is being retried), then it is registered in a sync map at the invocation service only for the first retry and cleared from the service when a response is finally received. This ensures that the user thread is always being notified. Exception architecture is compeletely changed so that we use std exception_ptr capabilities. Also integrated std::nested exceptions for exceptions which has a cause exception. The cause is obtained by using `std::rethrow_if_nested` method. The project now depends on boost::thread for boost::future. Changed cmake so that the boost installation is user's responsibility. Also using the boost Thread library version latest which is version 5.
Linux test FAILed. |
Windows test FAILed. |
@@ -190,7 +190,7 @@ namespace hazelcast { | |||
* @return an {@link ICompletableFuture} with the current value | |||
* @since cluster version 3.7 | |||
*/ | |||
std::shared_ptr<ICompletableFuture<int64_t> > getAsync(); | |||
future<std::shared_ptr<int64_t>> getAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not these be future<int64_t> ? Do we need shared ptr's for primitives ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we don't but I wıll change it when I change SerializationService to not use shared_ptr, this pointer is due to current serializationservice toObject
method.
@@ -1034,7 +1033,7 @@ namespace hazelcast { | |||
* @see ICompletableFuture | |||
* @see #setAsync(Object, Object) | |||
*/ | |||
std::shared_ptr<ICompletableFuture<V> > putAsync(const K &key, const V &value) { | |||
future<std::shared_ptr<V>> putAsync(const K &key, const V &value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use shared_future here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try not to use shared_future where future is enough. the user can convert it to shared_future using future::share() method anyway.
Windows test FAILed. |
Linux test FAILed. |
85511bb
to
1df90c0
Compare
Windows test FAILed. |
Linux test FAILed. |
Windows test FAILed. |
Linux test FAILed. |
Windows test FAILed. |
Linux test FAILed. |
…ConditionVariable`. Replaced them with standard and boost based implementations. Changed required boost version to 1.72.
Windows test FAILed. |
Linux test FAILed. |
Windows test FAILed. |
Linux test FAILed. |
Removed unneded include for windows (`WinSock2.h`) which causes error in compilation.
Windows test FAILed. |
Windows test FAILed. |
Linux test PASSed. |
… invocation service. Changed the CallIdSequence to use std::array of atomic integers.
Windows test FAILed. |
… for compiling successfully at Windows (fails due to `ambiguous symbol` error which can be both from std or boost namespaces).
Linux test FAILed. |
1 similar comment
Linux test FAILed. |
Windows test FAILed. |
Windows test FAILed. |
Linux test FAILed. |
Windows test FAILed. |
Linux test PASSed. |
Corrected the time string print utility. Replaced some of the time usages with std::chrono related ones. Made the timer cancel operations non-exception throwing. Replaced the system_clock usages with steady_clock usages. Warning fixes for windows for unused exceptions.
Windows test FAILed. |
Linux test FAILed. |
Windows test FAILed. |
Linux test PASSed. |
Some fixes so that the exceptions do not abort the io threads. Also, destroying the timer and pools upon shutdown so that no associated resource is left (which may happen for windows).
55f9a03
to
5f9c3ac
Compare
Windows test PASSed. |
Linux test PASSed. |
Changed the event processing executor usage to use asio::thread_pool.
Changed the ResponseThread to ResponseProcessor and it now processes the response message directly by default and will use a thread_pool if the newly introduced parameter
hazelcast.client.response.executor.thread.count
is set to a positive value.Removed custom Thread, Future implementations and used std::thread, boost::asio::thread_pool and boost::future/boost::promise.
boost::future supports continuation (
.then
support).Changed the invocation and event handler map design. Using an
unordered_map
which which only being accessed from the sameio
thread for the connection. This eliminated the need for using sync maps for invocations and events. If any other thread needs to access the invocations, it passes this request to io thread. This is only needed when closing the socket for notifying the outstanding invocations. If an invocation can not be queued into the connection (i.e. no connection exists for the invocation and it is being retried), then it is registered in a sync map at the invocation service only for the first retry and cleared from the service when a response is finally received. This ensures that the user thread is always being notified.Exception architecture is compeletely changed so that we use std exception_ptr capabilities. Also integrated std::nested exceptions for exceptions which has a cause exception. The cause is obtained by using
std::rethrow_if_nested
method.The project now depends on boost::thread for boost::future. Changed cmake so that the boost installation is user's responsibility. Also using the boost Thread library version latest which is version 5.