<commit_before>//
// Created by <NAME> on 31/03/14.
//

#ifndef HAZELCAST_Future
#define HAZELCAST_Future

#include "hazelcast/client/exception/IException.h"
#include "hazelcast/util/ConditionVariable.h"
#include "hazelcast/util/LockGuard.h"
#include "hazelcast/client/exception/ExceptionHandler.h"
#include <memory>
#include <cassert>

namespace hazelcast {
    namespace util {
        template <typename T>
        class HAZELCAST_API Future {
        public:
            Future()
            : resultReady(false)
            , exceptionReady(false) {

            };

            void set_value(const T &value) {
                LockGuard guard(mutex);
                assert( !(exceptionReady || resultReady) && "Value can not be set twice");
                sharedObject = value;
                resultReady = true;
                conditionVariable.notify_all();
            };

            void set_exception(const std::string &exceptionName, const std::string &exceptionDetails) {
                LockGuard guard(mutex);
                assert( !(exceptionReady || resultReady) && "Exception can not be set twice");
                this->exceptionName = exceptionName;
                this->exceptionDetails = exceptionDetails;
                exceptionReady = true;
                conditionVariable.notify_all();
            };

            T get() {
                LockGuard guard(mutex);
                if (resultReady) {
                    return sharedObject;
                }<commit_msg>change assert to warning log in future.h<commit_after>//
// Created by <NAME> on 31/03/14.
//

#ifndef HAZELCAST_Future
#define HAZELCAST_Future

#include "hazelcast/client/exception/IException.h"
#include "hazelcast/util/ConditionVariable.h"
#include "hazelcast/util/LockGuard.h"
#include "hazelcast/client/exception/ExceptionHandler.h"
#include "hazelcast/util/ILogger.h"
#include <memory>
#include <cassert>

namespace hazelcast {
    namespace util {
        template <typename T>
        class HAZELCAST_API Future {
        public:
            Future()
            : resultReady(false)
            , exceptionReady(false) {

            };

            void set_value(const T &value) {
                LockGuard guard(mutex);
                if( exceptionReady || resultReady ) {
                    util::ILogger::getLogger().warning(std::string("Future.set_value should not be called twice" ) );
                    return;
                }
                sharedObject = value;
                resultReady = true;
                conditionVariable.notify_all();
            };

            void set_exception(const std::string &exceptionName, const std::string &exceptionDetails) {
                LockGuard guard(mutex);
                if( exceptionReady || resultReady ) {
                    util::ILogger::getLogger().warning(std::string("Future.set_exception should not be called twice" ));
                    return;
                }
                this->exceptionName = exceptionName;
                this->exceptionDetails = exceptionDetails;
                exceptionReady = true;
                conditionVariable.notify_all();
            };

            T get() {
                LockGuard guard(mutex);
                if (resultReady) {
                    return sharedObject;
                }
{'fraction_non_alphanumeric': 0.096996996996997, 'fraction_numerical': 0.0036036036036036037, 'mean_word_length': 1.794463087248322, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4320246', 'n_tokens_mistral': 880, 'n_tokens_neox': 828, 'n_words': 188}