Hey, this is an English text. I want you to translate it into the Tunisian dialect.…
- User
Hey, this is an English text. I want you to translate it into the Tunisian dialect. Please follow these steps:
- Translate step by step and highlight differences between Tunisian dialect and Modern Standard Arabic.
- Highlight sections you are confident translating into the Tunisian dialect. Translate this text into the Tunisian dialect, focusing on capturing the essence of the language nuances:
//------------------------------------------------------------------------------ /* This file is part of rippled: https://github.com/ripple/rippled Copyright 2014 Ripple Labs Inc. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. / //============================================================================== #include <BeastConfig.h> #include <ripple/basics/make_SSLContext.h> #include <ripple/beast/core/CurrentThreadName.h> #include <ripple/beast/unit_test.h> #include <boost/asio.hpp> #include <boost/asio/ssl.hpp> #include <boost/optional.hpp> #include <boost/utility/in_place_factory.hpp> #include #include <condition_variable> #include #include #include #include namespace ripple { / Findings from the test: If the remote host calls async_shutdown then the local host's async_read will complete with eof. If both hosts call async_shutdown then the calls to async_shutdown will complete with eof. / class short_read_test : public beast::unit_test::suite { private: using io_service_type = boost::asio::io_service; using strand_type = io_service_type::strand; using timer_type = boost::asio::basic_waitable_timer< std::chrono::steady_clock>; using acceptor_type = boost::asio::ip::tcp::acceptor; using socket_type = boost::asio::ip::tcp::socket; using stream_type = boost::asio::ssl::stream<socket_type&>; using error_code = boost::system::error_code; using endpoint_type = boost::asio::ip::tcp::endpoint; using address_type = boost::asio::ip::address; io_service_type io_service_; boost::optional<io_service_type::work> work_; std::thread thread_; std::shared_ptrboost::asio::ssl::context context_; static endpoint_type endpoint() { return endpoint_type(address_type::from_string("127.0.0.1"), 9000); } template static void write(Streambuf& sb, std::string const& s) { using boost::asio::buffer; using boost::asio::buffer_copy; using boost::asio::buffer_size; boost::asio::const_buffers_1 buf(s.data(), s.size()); sb.commit(buffer_copy(sb.prepare(buffer_size(buf)), buf)); } //-------------------------------------------------------------------------- class Base { protected: class Child { private: Base& base_; public: Child(Base& base) : base_(base) { } virtual ~Child() { base_.remove(this); } virtual void close() = 0; }; private: std::mutex mutex_; std::condition_variable cond_; std::map<Child, std::weak_ptr> list_; bool closed_ = false; public: ~Base() { // Derived class must call wait() in the destructor assert(list_.empty()); } void add (std::shared_ptr const& child) { std::lock_guard lock(mutex_); list_.emplace(child.get(), child); } void remove (Child* child) { std::lock_guard lock(mutex_); list_.erase(child); if (list_.empty()) cond_.notify_one(); } void close() { std::vector<std::shared_ptr> v; { std::lock_guard lock(mutex_); v.reserve(list_.size()); if (closed_) return; closed_ = true; for(auto const& c : list_) { if(auto p = c.second.lock()) { p->close(); // Must destroy shared_ptr outside the // lock otherwise deadlock from the // managed object's destructor. v.emplace_back(std::move(p)); } } } } void wait() { std::unique_lock lock(mutex_); while(! list_.empty()) cond_.wait(lock); } }; //-------------------------------------------------------------------------- class Server : public Base { private: short_read_test& test_; struct Acceptor : Child, std::enable_shared_from_this { Server& server_; short_read_test& test_; acceptor_type acceptor_; socket_type socket_; strand_type strand_; Acceptor(Server& server) : Child(server) , server_(server) , test_(server_.test_) , acceptor_(test_.io_service_, endpoint()) , socket_(test_.io_service_) , strand_(socket_.get_io_service()) { acceptor_.listen(); } void close() override { if(! strand_.running_in_this_thread()) return strand_.post(std::bind(&Acceptor::close, shared_from_this())); acceptor_.close(); } void run() { acceptor_.async_accept(socket_, strand_.wrap(std::bind( &Acceptor::on_accept, shared_from_this(), std::placeholders::.is_open()) { if (ec != boost::asio::error::operation_aborted) test_.log << what << ": " << ec.message()
- Assistant