diff --git a/MDB/imm_mongodb/mongocxx/options/create_collection.hpp b/MDB/imm_mongodb/mongocxx/options/create_collection.hpp index 7b3e5a5..8da3338 100644 --- a/MDB/imm_mongodb/mongocxx/options/create_collection.hpp +++ b/MDB/imm_mongodb/mongocxx/options/create_collection.hpp @@ -161,12 +161,12 @@ class MONGOCXX_API create_collection_deprecated { const stdx::optional& size() const; /// - /// Specify configuration to the message_base on a per-collection basis. + /// Specify configuration to the storage on a per-collection basis. /// - /// @note This option is currently only available with the WiredTiger message_base engine. + /// @note This option is currently only available with the WiredTiger storage engine. /// /// @param storage_engine_opts - /// Configuration options specific to the message_base engine. + /// Configuration options specific to the storage engine. /// /// @return /// A reference to the object on which this member function is being called. This facilitates @@ -176,10 +176,10 @@ class MONGOCXX_API create_collection_deprecated { bsoncxx::document::view_or_value storage_engine_opts); /// - /// Gets the current message_base engine configuration for this collection. + /// Gets the current storage engine configuration for this collection. /// /// @return - /// Configuration options specific to the message_base engine. + /// Configuration options specific to the storage engine. /// const stdx::optional& storage_engine() const; diff --git a/MDB/imm_mongodb/mongocxx/options/index.hpp b/MDB/imm_mongodb/mongocxx/options/index.hpp index 519862c..001cf43 100644 --- a/MDB/imm_mongodb/mongocxx/options/index.hpp +++ b/MDB/imm_mongodb/mongocxx/options/index.hpp @@ -41,7 +41,7 @@ namespace options { class MONGOCXX_API index { public: /// - /// Base class representing the optional message_base engine options for indexes. + /// Base class representing the optional storage engine options for indexes. /// class MONGOCXX_API base_storage_options { public: @@ -53,7 +53,7 @@ class MONGOCXX_API index { }; /// - /// Class representing the optional WiredTiger message_base engine options for indexes. + /// Class representing the optional WiredTiger storage engine options for indexes. /// class MONGOCXX_API wiredtiger_storage_options final : public base_storage_options { public: @@ -216,11 +216,11 @@ class MONGOCXX_API index { const stdx::optional& sparse() const; /// - /// Optionally used only in MongoDB 3.0.0 and higher. Specifies the message_base engine options for + /// Optionally used only in MongoDB 3.0.0 and higher. Specifies the storage engine options for /// the index. /// /// @param storage_options - /// The message_base engine options for the index. + /// The storage engine options for the index. /// /// @return /// A reference to the object on which this member function is being called. This facilitates @@ -229,11 +229,11 @@ class MONGOCXX_API index { index& storage_options(std::unique_ptr storage_options); /// - /// Optionally used only in MongoDB 3.0.0 and higher. Specifies the WiredTiger-specific message_base + /// Optionally used only in MongoDB 3.0.0 and higher. Specifies the WiredTiger-specific storage /// engine options for the index. /// /// @param storage_options - /// The message_base engine options for the index. + /// The storage engine options for the index. /// index& storage_options(std::unique_ptr storage_options); diff --git a/MDB/imm_mongodb/mongocxx/read_concern.hpp b/MDB/imm_mongodb/mongocxx/read_concern.hpp index 0e58b7f..5e1855d 100644 --- a/MDB/imm_mongodb/mongocxx/read_concern.hpp +++ b/MDB/imm_mongodb/mongocxx/read_concern.hpp @@ -37,7 +37,7 @@ class uri; /// collection level. The read concern can also be provided via connection string, and will be /// parsed and set on the client constructed for the URI. /// -/// For the WiredTiger message_base engine, MongoDB 3.2 introduced the readConcern option for replica +/// For the WiredTiger storage engine, MongoDB 3.2 introduced the readConcern option for replica /// sets and replica set shards. The readConcern option allows clients to choose a level of /// isolation for their reads. You can specify a readConcern of "majority" to read data that has /// been written to a majority of nodes and thus cannot be rolled back. By default, MongoDB uses a @@ -45,7 +45,7 @@ class uri; /// /// MongoDB 3.4 introduces a read concern level of "linearizable" to read data that has been written /// to a majority of nodes (i.e. cannot be rolled back) @b and is not stale. Linearizable read -/// concern is available for all MongoDB supported message_base engines and applies to read operations on +/// concern is available for all MongoDB supported storage engines and applies to read operations on /// a single document. Note that writes must be made with majority write concern in order for reads /// to be linearizable. /// diff --git a/MP/IMDataPacket.cpp b/MP/IMDataPacket.cpp index 79c50fc..55f987b 100644 --- a/MP/IMDataPacket.cpp +++ b/MP/IMDataPacket.cpp @@ -18,11 +18,10 @@ IMDataPacket::IMDataPacket(mp::MP_TYPE type, mp::MP_SUB_TYPE subType, } -IMDataPacket::IMDataPacket(mp::MP_TYPE type, mp::MP_SUB_TYPE subType, +IMDataPacket::IMDataPacket(mp::MP_TYPE type, /*mp::MP_SUB_TYPE subType,*/ uint64_t messageId, time_t time) : Mph(type), - MsgData(subType, messageId, time) { - + MsgData(messageId, time) { } std::string IMDataPacket::packet() { diff --git a/MP/IMDataPacket.h b/MP/IMDataPacket.h index 1514d16..d15455c 100644 --- a/MP/IMDataPacket.h +++ b/MP/IMDataPacket.h @@ -12,13 +12,35 @@ class IMDataPacket : public Mph, MsgData { public: + + /** + * 消息包 + * @param type 包类型 + * @param data protobuf 定义的 消息包类型 + */ IMDataPacket(mp::MP_TYPE type, mp::im::msg_data* data); + /** + * 消息包 + * @param type 包类型 + * @param subType 消息类型 + * @param sessionType 会话类型 + * @param messageId 消息id + * @param time 时间 + * @param account 来源 + * @param imMsgData 数据 + */ IMDataPacket(mp::MP_TYPE type, mp::MP_SUB_TYPE subType, mp::MP_SUB_TYPE sessionType, uint64_t messageId, time_t time, uint64_t account, const std::string &imMsgData); - IMDataPacket(mp::MP_TYPE type, mp::MP_SUB_TYPE subType, + /** + * 通知包 + * @param type 包类型 + * @param messageId 消息id + * @param time 消息时间 + */ + IMDataPacket(mp::MP_TYPE type, /*mp::MP_SUB_TYPE subType,*/ uint64_t messageId, time_t time); public: diff --git a/MP/MsgData.h b/MP/MsgData.h index 5f6989b..de34520 100644 --- a/MP/MsgData.h +++ b/MP/MsgData.h @@ -29,6 +29,12 @@ public: data->set_time(time); } + MsgData(uint64_t message_id, time_t time) { + data = new mp::im::msg_data(); + data->set_message_id(message_id); + data->set_time(time); + } + virtual ~MsgData() { delete data; } diff --git a/MP/protohuf/mp.mp.proto b/MP/protohuf/mp.mp.proto index 68c6b62..4d0af53 100644 --- a/MP/protohuf/mp.mp.proto +++ b/MP/protohuf/mp.mp.proto @@ -86,6 +86,8 @@ enum MP_SUB_TYPE { MP_ADD_CHECK = 80; // 需要回答问题的好友/群组 验证问题 + MP_TYPE_NULL = 100; // 类型无意义 用于填充 + ///***********************************************************************************/// /// 200+ IM ***********************************************************************************/// diff --git a/MS/mmm/session.cpp b/MS/mmm/session.cpp index 4fe3ef2..c131f37 100644 --- a/MS/mmm/session.cpp +++ b/MS/mmm/session.cpp @@ -16,6 +16,23 @@ session::session() { printf("timing end\n"); } +session::session(session_build_type type) { + if (type == SESSION_SUPPORT_ALL) { + printf("timing begin\n"); + timing(); + printf("timing end\n"); + + } else if (type == SESSION_SUPPORT_SESSION) { + printf("timing begin\n"); + timing(); + printf("timing end\n"); + } + + else if (type == SESSION_SUPPORT_USER) { + + } +} + /// curr mem user curd user session void session::add_user(mp::sri* sri, std::shared_ptr& request) { if (sri->subcommand() == mp::MP_LOGIN_SUCCESS) { @@ -75,6 +92,7 @@ void session::init_session(bufferevent *bev) { } + // 给用户 添加会话信息 void session::set_session(bufferevent* bev, const std::string &session_key, const std::string &session_value) { printf("code: %s\n", session_value.c_str()); @@ -198,3 +216,5 @@ std::optional session::find_user(uint64_t account) { + + diff --git a/MS/mmm/session.h b/MS/mmm/session.h index af0ac06..f69d69c 100644 --- a/MS/mmm/session.h +++ b/MS/mmm/session.h @@ -25,10 +25,23 @@ struct bev_key { std::string value; }; +enum session_build_type { + SESSION_SUPPORT_USER = 0, + SESSION_SUPPORT_SESSION = 1, + SESSION_SUPPORT_ALL = 2, +}; + class session { public: + /** + * 空构造是 全部支持 + */ session(); + /** + * 选择支持 + */ + session(session_build_type type); public: // 添加用户 @@ -45,6 +58,7 @@ public: bool is_user(const std::string& account); // 是否有这个用户 bool is_user(uint64_t account); + // 初始化 session void init_session(bufferevent* bev); // 设置 session diff --git a/MS/works/CMakeLists.txt b/MS/works/CMakeLists.txt index 6a16285..ac3b0be 100644 --- a/MS/works/CMakeLists.txt +++ b/MS/works/CMakeLists.txt @@ -7,6 +7,7 @@ aux_source_directory(db/po DIR_WORKS_DB_PO) include_directories(../mmm) include_directories(${CMAKE_SOURCE_DIR}/MDB/imm_mysqldb) +include_directories(${CMAKE_SOURCE_DIR}/MessageSystem) add_library(works ${DIR_WORKS_CONTROLLER} diff --git a/MS/works/controller/IMController.cpp b/MS/works/controller/IMController.cpp index e933e37..27aa90e 100644 --- a/MS/works/controller/IMController.cpp +++ b/MS/works/controller/IMController.cpp @@ -3,14 +3,8 @@ // #include "IMController.h" +#include "message_push/MessageMgr.h" void IMController::run(std::shared_ptr request, std::shared_ptr response) { - // msg push 储存库内 正常会话 要同步库 储存库 - if (request->m_mph->mp_type() == mp::MP_IM_PUSH_MSG) { - - } - // 传来 im msg 临时会话 消息包本体 要同步库 - else if (request->m_mph->mp_type() == mp::MP_IM_MSG) { - - } + MessageMgr(); } diff --git a/MessageSystem/CMakeLists.txt b/MessageSystem/CMakeLists.txt index 3fdbe62..62509c5 100644 --- a/MessageSystem/CMakeLists.txt +++ b/MessageSystem/CMakeLists.txt @@ -1,18 +1,28 @@ project(MessageSystem) -aux_source_directory(message_push PUSH) -aux_source_directory(message_base BASE) -aux_source_directory(message_pull PULL) -aux_source_directory(timeline_safe SAFE_QUEUE) +aux_source_directory(message_push PUSH) +aux_source_directory(message_push/online ONLINE) +aux_source_directory(message_push/offline OFFLINE) +aux_source_directory(message_storage STORAGE) +aux_source_directory(message_pull PULL) +aux_source_directory(message_safe SAFE_QUEUE) +aux_source_directory(message_base BASE) +include_directories(${CMAKE_SOURCE_DIR}/include/libevent) include_directories(${CMAKE_SOURCE_DIR}/MP) include_directories(${CMAKE_SOURCE_DIR}/MDB/imm_mongodb) +include_directories(${CMAKE_SOURCE_DIR}/MessageSystem) +include_directories(${CMAKE_SOURCE_DIR}/MS/mmm) + add_library(MessageSystem ${PUSH} - ${BASE} + ${ONLINE} + ${OFFLINE} + ${STORAGE} ${PULL} ${SAFE_QUEUE} + ${BASE} ) target_link_libraries(MessageSystem diff --git a/MessageSystem/message_base/Storage.cpp b/MessageSystem/message_base/Storage.cpp deleted file mode 100644 index 705aed2..0000000 --- a/MessageSystem/message_base/Storage.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// -// Created by dongl on 23-5-29. -// - -#include "Storage.h" -#include "template/MsgTemplate.h" - -#include -#include - -MSG::Storage::Storage(TimeLine *timeLine, db_base* db) - : m_timeLine(timeLine), m_db(db), m_db_name(""), m_table("") { - storage_push_queue(); -} - -MSG::Storage::Storage(std::string&& db_name, std::string&& table) : m_db_name(db_name), m_table(table) { - m_timeLine = new TimeLine(); - m_db = new db_base(); - storage_push_queue(); -} - -// 储存库 push -void MSG::Storage::push(StorageMsg* msg) { - // 添加至队列 - m_timeLine->push(msg); -} - -void MSG::Storage::pull() { - auto coll = m_db->hit_db_coll(m_db_name, m_table); -} - - -void MSG::Storage::storage_push_queue() { - std::function fun = [&] { - // 取mongo链接 - auto coll = m_db->hit_db_coll(m_db_name, m_table); - - while (true) { - while (!m_timeLine->value().empty()) { -// if (m_timeLine->value().size() > 10) { -// /// 插入多个 -// } else -// { - /// 插入单个 - // 弹出msg队列 此cpp只负责储存库 不负责同步库 - auto msg = m_timeLine->pull(); - // 执行插入 - auto insert_one_result = coll.insert_one(MsgTemplate::session_msg(msg->msg_type, msg->session_type, - msg->message_id, msg->time, msg->account, msg->im_msg_data)); - - auto doc_id = insert_one_result->inserted_id(); - printf("[msg insert mongo] %s\n", doc_id.type() == bsoncxx::type::k_oid ? "msg insert" : "not msg insert"); -// } - } - } - }; - - for (int i = 0; i < 2; ++i) { - std::thread t(fun); - printf("%ld", t.get_id()); - t.detach(); - } -} - - - diff --git a/MessageSystem/message_base/Syn.cpp b/MessageSystem/message_base/Syn.cpp deleted file mode 100644 index 4d4a0d7..0000000 --- a/MessageSystem/message_base/Syn.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// -// Created by dongl on 23-7-1. -// - -#include "Syn.h" diff --git a/MessageSystem/message_base/Syn.h b/MessageSystem/message_base/Syn.h deleted file mode 100644 index 3d9b142..0000000 --- a/MessageSystem/message_base/Syn.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// Created by dongl on 23-7-1. -// - -#ifndef IM2_SYN_H -#define IM2_SYN_H - -namespace MSG { - class Syn { - - }; -} - -#endif //IM2_SYN_H diff --git a/MessageSystem/message_base/db_base.cpp b/MessageSystem/message_base/db_base.cpp index b55154d..8aa6f16 100644 --- a/MessageSystem/message_base/db_base.cpp +++ b/MessageSystem/message_base/db_base.cpp @@ -3,8 +3,8 @@ // #include "db_base.h" -#include -#include +#include "mongocxx/instance.hpp" +#include "mongocxx/uri.hpp" db_base::db_base() { @@ -12,6 +12,10 @@ db_base::db_base() { mongocxx::uri uri("mongodb://user_session:Aa316216@124.221.152.192:27017/?authSource=im_session"); pool = new mongocxx::pool(uri); } +db_base::~db_base() { + delete pool; +} + mongocxx::pool::entry db_base::acquire() { return pool->acquire(); @@ -33,3 +37,4 @@ mongocxx::collection db_base::hit_db_coll(const std::string& db_name, const std: + diff --git a/MessageSystem/message_base/db_base.h b/MessageSystem/message_base/db_base.h index cd12631..1fc82ef 100644 --- a/MessageSystem/message_base/db_base.h +++ b/MessageSystem/message_base/db_base.h @@ -5,10 +5,10 @@ #ifndef IM2_DB_BASE_H #define IM2_DB_BASE_H -#include -#include -#include -#include +#include "mongocxx/pool.hpp" +#include "mongocxx/stdx.hpp" +#include "bsoncxx/stdx/optional.hpp" +#include "mongocxx/client.hpp" using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_array; @@ -17,6 +17,9 @@ using bsoncxx::builder::basic::make_document; class db_base { public: db_base(); + + virtual ~db_base(); + mongocxx::pool::entry acquire(); bsoncxx::stdx::optional try_acquire(); @@ -24,7 +27,7 @@ public: // 命中 库 表 mongocxx::collection hit_db_coll(const std::string& db_name, const std::string& coll); -private: +protected: mongocxx::pool* pool = nullptr; }; diff --git a/MessageSystem/message_push/MessageMgr.cpp b/MessageSystem/message_push/MessageMgr.cpp new file mode 100644 index 0000000..1bb63f0 --- /dev/null +++ b/MessageSystem/message_push/MessageMgr.cpp @@ -0,0 +1,43 @@ +// +// Created by dongl on 23-7-4. +// + +#include "MessageMgr.h" +#include "message_push/online/OnlineMessageMgr.h" +#include "message_push/offline/OfflineMessageMgr.h" +#include "IMDataPacket.h" + +session* MessageMgr::session = new class session(SESSION_SUPPORT_USER); + +MessageMgr::~MessageMgr() { + delete session; +} + + +void MessageMgr::receive(const std::string &packet) { + +} + +void MessageMgr::send(const std::string &packet) { + +} + + +// 接收 +void MessageMgr::receive(const agreement_request& request) { + // 查看用户是否在线 + bool is_exist = session->is_user(request.m_body.account()); + if (is_exist) { + OnlineMessageMgr(); + } else { + OfflineMessageMgr(); + } +} + +// 发送 +void MessageMgr::send(const agreement_response& response) { + IMDataPacket imDataPacket(mp::MP_TYPE::MP_IM_NOTICE, response.m_notice->time(), (time_t)response.m_notice->message_id()); + std::string packet = imDataPacket.packet(); + bufferevent_write(response.m_bev, packet.c_str(), packet.size()); +} + diff --git a/MessageSystem/message_push/MessageMgr.h b/MessageSystem/message_push/MessageMgr.h new file mode 100644 index 0000000..6939b2d --- /dev/null +++ b/MessageSystem/message_push/MessageMgr.h @@ -0,0 +1,45 @@ +// +// Created by dongl on 23-7-4. +// + +#ifndef IM2_MESSAGEMGR_H +#define IM2_MESSAGEMGR_H + + +#include +#include "agreement.h" +#include "session.h" + +class MessageMgr { +public: + virtual ~MessageMgr(); + +public: + /** + * 接受消息 + * @param request const std::string 消息包原始二进制数据 + */ + static void receive(const std::string& packet); + /** + * 已服务器为主体 的 发送消息 + * @param response const std::string 消息包原始二进制数据 + */ + static void send(const std::string& packet); + + /** + * 接受消息 + * @param request agreement_request 解析好的消息协议 + */ + static void receive(const agreement_request& request); + /** + * 已服务器为主体 的 发送消息 + * @param response agreement_response 解析好的消息协议 + */ + static void send(const agreement_response& response); + +private: + static class session* session; +}; + + +#endif //IM2_MESSAGEMGR_H diff --git a/MessageSystem/message_push/offline/OfflineMessageMgr.cpp b/MessageSystem/message_push/offline/OfflineMessageMgr.cpp new file mode 100644 index 0000000..4bfbb5b --- /dev/null +++ b/MessageSystem/message_push/offline/OfflineMessageMgr.cpp @@ -0,0 +1,5 @@ +// +// Created by dongl on 23-7-4. +// + +#include "OfflineMessageMgr.h" diff --git a/MessageSystem/message_push/offline/OfflineMessageMgr.h b/MessageSystem/message_push/offline/OfflineMessageMgr.h new file mode 100644 index 0000000..6ddd37d --- /dev/null +++ b/MessageSystem/message_push/offline/OfflineMessageMgr.h @@ -0,0 +1,14 @@ +// +// Created by dongl on 23-7-4. +// + +#ifndef IM2_OFFLINEMESSAGEMGR_H +#define IM2_OFFLINEMESSAGEMGR_H + + +class OfflineMessageMgr { + +}; + + +#endif //IM2_OFFLINEMESSAGEMGR_H diff --git a/MessageSystem/message_push/online/OnlineMessageMgr.cpp b/MessageSystem/message_push/online/OnlineMessageMgr.cpp new file mode 100644 index 0000000..93121dc --- /dev/null +++ b/MessageSystem/message_push/online/OnlineMessageMgr.cpp @@ -0,0 +1,5 @@ +// +// Created by dongl on 23-7-4. +// + +#include "OnlineMessageMgr.h" diff --git a/MessageSystem/message_push/online/OnlineMessageMgr.h b/MessageSystem/message_push/online/OnlineMessageMgr.h new file mode 100644 index 0000000..ce3290b --- /dev/null +++ b/MessageSystem/message_push/online/OnlineMessageMgr.h @@ -0,0 +1,17 @@ +// +// Created by dongl on 23-7-4. +// + +#ifndef IM2_ONLINEMESSAGEMGR_H +#define IM2_ONLINEMESSAGEMGR_H + + +class OnlineMessageMgr { +public: + +private: + +}; + + +#endif //IM2_ONLINEMESSAGEMGR_H diff --git a/MessageSystem/timeline_safe/TimeLine.cpp b/MessageSystem/message_safe/SafeQueue.cpp similarity index 71% rename from MessageSystem/timeline_safe/TimeLine.cpp rename to MessageSystem/message_safe/SafeQueue.cpp index 70a8202..897a813 100644 --- a/MessageSystem/timeline_safe/TimeLine.cpp +++ b/MessageSystem/message_safe/SafeQueue.cpp @@ -2,6 +2,5 @@ // Created by dongl on 23-5-17. // -#include "TimeLine.h" - +#include "SafeQueue.h" #include diff --git a/MessageSystem/message_safe/SafeQueue.h b/MessageSystem/message_safe/SafeQueue.h new file mode 100644 index 0000000..da5328f --- /dev/null +++ b/MessageSystem/message_safe/SafeQueue.h @@ -0,0 +1,103 @@ +// +// Created by dongl on 23-5-17. +// + +#ifndef IM2_TIMELINE_H +#define IM2_SAFEQUEUE_H + +#include +#include +#include "proto/mp.mp.pb.h" +#include "message_base/db_base.h" + + +struct SynMsg { + uint64_t message_id; + time_t time; +}; + +struct StorageMsg { + mp::MP_SUB_TYPE msg_type; + mp::MP_SUB_TYPE session_type; + int64_t message_id; + time_t time; + int64_t account; + std::string im_msg_data; +}; + +template +class SafeQueue { +public: + /** + * 压入元素 + * @param ele T 类型的 + */ + void push(T ele) { + mutex.lock(); + queue.push(ele); + mutex.unlock(); + } + + /** + * 弹出元素 并 删除 + * @return T + */ + T pull() { + std::lock_guard lockGuard(mutex); + auto ele = queue.front(); + queue.pop(); + return ele; + } + + /** + * 头部元素 + * @return T + */ + T front() { + std::lock_guard lockGuard(mutex); + return queue.front(); + } + + /** + * 查询第二个元素 + * @return T + */ + T index_second() { + if (1 >= queue.size()) { + perror("查询越界\n"); + return nullptr; + } + std::lock_guard lockGuard(mutex); + return *((&queue.front()) + 1); + } + + /** + * 查询 距离 front 向右的第i个位置 + * @param i 距离 front 向右的第i个位置 + * @return T + */ + T index_second_n(uint32_t i) { + if (i >= queue.size()) { + perror("查询越界\n"); + return nullptr; + } + std::lock_guard lockGuard(mutex); + return *((&queue.front()) + i); + } + + /** + * 获取队列本身 not safe 的 + * @return std::queue + */ + std::queue& value() { + return queue; + } +private: + std::mutex mutex; + std::queue queue; +}; + + + + +#endif //IM2_TIMELINE_H diff --git a/MessageSystem/message_storage/Storage.cpp b/MessageSystem/message_storage/Storage.cpp new file mode 100644 index 0000000..9bd3c28 --- /dev/null +++ b/MessageSystem/message_storage/Storage.cpp @@ -0,0 +1,64 @@ +// +// Created by dongl on 23-5-29. +// + +#include "Storage.h" +#include "template/MsgTemplate.h" +#include "IMDataPacket.h" + +#include +#include + +MSG::Storage::Storage(SafeQueue *timeLine, db_base* db) + : m_timeLine(timeLine), m_db_name(""), m_table("") { + storage_push_lister_queue(); +} + +MSG::Storage::Storage(std::string&& db_name, std::string&& table) : m_db_name(db_name), m_table(table) { + m_timeLine = new SafeQueue(); + storage_push_lister_queue(); +} + +MSG::Storage::~Storage() { + delete m_timeLine; +} + +// 储存库 push +void MSG::Storage::push(StorageMsg* msg) { + // 添加至队列 + m_timeLine->push(msg); +} + + +void MSG::Storage::storage_push_lister_queue() { + std::function fun = [&] { + // 取mongo链接 + auto coll = hit_db_coll(m_db_name, m_table); + + while (true) { + while (!m_timeLine->value().empty()) { + /// 插入单个 + // 弹出msg队列 此cpp只负责储存库 不负责同步库 + auto msg = m_timeLine->pull(); + // 执行插入 + auto insert_one_result = coll.insert_one(MsgTemplate::session_msg(msg->msg_type, msg->session_type, + msg->message_id, msg->time, msg->account, msg->im_msg_data)); + + auto doc_id = insert_one_result->inserted_id(); + printf("[msg insert mongo] %s\n", doc_id.type() == bsoncxx::type::k_oid ? "msg insert" : "not msg insert"); + } + } + }; + + for (int i = 0; i < 2; ++i) { + std::thread t(fun); + printf("%ld", t.get_id()); + t.detach(); + } +} + + + + + + diff --git a/MessageSystem/message_base/Storage.h b/MessageSystem/message_storage/Storage.h similarity index 51% rename from MessageSystem/message_base/Storage.h rename to MessageSystem/message_storage/Storage.h index 0b3a9d8..c54d4db 100644 --- a/MessageSystem/message_base/Storage.h +++ b/MessageSystem/message_storage/Storage.h @@ -6,24 +6,24 @@ #define IM2_STORAGE_H -#include "db_base.h" -#include "../timeline_safe/TimeLine.h" +#include "message_base/db_base.h" +#include "message_safe/SafeQueue.h" namespace MSG { - class Storage { + class Storage : db_base { public: - Storage(TimeLine *timeLine, db_base* db); + Storage(SafeQueue *timeLine, db_base* db); Storage(std::string&& db_name, std::string&& table); + virtual ~Storage(); + public: void push(StorageMsg* msg); - void pull(); - void storage_push_queue(); + void storage_push_lister_queue(); private: - db_base* m_db = nullptr; - TimeLine * m_timeLine = nullptr; + SafeQueue * m_timeLine = nullptr; std::string m_db_name, m_table; }; diff --git a/MessageSystem/message_storage/Syn.cpp b/MessageSystem/message_storage/Syn.cpp new file mode 100644 index 0000000..7d2440c --- /dev/null +++ b/MessageSystem/message_storage/Syn.cpp @@ -0,0 +1,43 @@ +// +// Created by dongl on 23-7-1. +// + +#include +#include "Syn.h" +#include "IMDataPacket.h" + +MSG::Syn::Syn(SafeQueue *mTimeLine) : m_timeLine(mTimeLine) {} + +MSG::Syn::Syn() : m_timeLine(new SafeQueue) { + +} + +MSG::Syn::~Syn() { + delete m_timeLine; +} + +void MSG::Syn::push(SynMsg* msg) { + m_timeLine->push(msg); +} + +void MSG::Syn::syn_push_lister_queue(const std::function& cb) { + std::function fun = [&] { + while (true) { + while (!m_timeLine->value().empty()) { + SynMsg* msg = m_timeLine->pull(); + IMDataPacket imDataPacket(mp::MP_IM_NOTICE, msg->message_id, msg->time); + + // 执行回调 + cb(imDataPacket.packet()); + } + } + }; + + for (int i = 0; i < 2; ++i) { + std::thread t(fun); + printf("[thread id] %ld\n", t.get_id()); + t.detach(); + } +} + + diff --git a/MessageSystem/message_storage/Syn.h b/MessageSystem/message_storage/Syn.h new file mode 100644 index 0000000..0953720 --- /dev/null +++ b/MessageSystem/message_storage/Syn.h @@ -0,0 +1,26 @@ +// +// Created by dongl on 23-7-1. +// + +#ifndef IM2_SYN_H +#define IM2_SYN_H + +#include "message_safe/SafeQueue.h" + +namespace MSG { + class Syn : public db_base { + public: + explicit Syn(SafeQueue *mTimeLine); + explicit Syn(); + virtual ~Syn(); + + public: + void push(SynMsg* msg); + void syn_push_lister_queue(const std::function&); + + private: + SafeQueue* m_timeLine = nullptr; + }; +} + +#endif //IM2_SYN_H diff --git a/MessageSystem/timeline_safe/TimeLine.h b/MessageSystem/timeline_safe/TimeLine.h deleted file mode 100644 index 7f55e95..0000000 --- a/MessageSystem/timeline_safe/TimeLine.h +++ /dev/null @@ -1,55 +0,0 @@ -// -// Created by dongl on 23-5-17. -// - -#ifndef IM2_TIMELINE_H -#define IM2_TIMELINE_H - -#include -#include -#include "proto/mp.mp.pb.h" -#include "storage/db_base.h" - - -struct SynMsg { - uint64_t message_id; - time_t time; -}; - -struct StorageMsg { - mp::MP_SUB_TYPE msg_type; - mp::MP_SUB_TYPE session_type; - int64_t message_id; - time_t time; - int64_t account; - std::string im_msg_data; -}; - -template -class TimeLine { -public: - void push(T ele) { - mutex.lock(); - queue.push(ele); - mutex.unlock(); - } - - T pull() { - std::lock_guard lockGuard(mutex); - auto ele = queue.front(); - queue.pop(); - return ele; - } - - std::queue& value() { - return queue; - } -private: - std::mutex mutex; - std::queue queue; -}; - - - - -#endif //IM2_TIMELINE_H diff --git a/TEST/main.cpp b/TEST/main.cpp index b44d1ef..a0ae523 100644 --- a/TEST/main.cpp +++ b/TEST/main.cpp @@ -9,9 +9,8 @@ #include "works/db/UserFriendsDB.h" #include "works/db/UserDB.h" #include "smtp/send_email.h" -#include "storage/Storage.h" #include "IMDataPacket.h" -#include "template/MsgTemplate.h" +#include "message_storage/Storage.h" int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); @@ -147,4 +146,27 @@ TEST (MP_IM_PUSH_MSG, MP_IM_PUSH_MSG_TEST) { storage->push(msg); sleep(10); -} \ No newline at end of file +} + +TEST(queue, queue_test) { + std::queue queue; + queue.push(1); + queue.push(2); + + printf("%d", *((&queue.front()) + 1)); +} + + + + + + + + + + + + + + + diff --git a/include/google/protobuf/arena.h b/include/google/protobuf/arena.h index 0c9ac7d..038553c 100644 --- a/include/google/protobuf/arena.h +++ b/include/google/protobuf/arena.h @@ -357,7 +357,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // the call to this method. uint64 SpaceUsed() const { return impl_.SpaceUsed(); } - // Frees all message_base allocated by this arena after calling destructors + // Frees all storage allocated by this arena after calling destructors // registered with OwnDestructor() and freeing objects registered with Own(). // Any objects allocated on this arena are unusable after this call. It also // returns the total space used by the arena which is the sums of the sizes diff --git a/include/google/protobuf/arena_impl.h b/include/google/protobuf/arena_impl.h index 7ade732..5a95124 100644 --- a/include/google/protobuf/arena_impl.h +++ b/include/google/protobuf/arena_impl.h @@ -289,7 +289,7 @@ class PROTOBUF_EXPORT ArenaImpl { static std::atomic lifecycle_id_generator_; #if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) // Android ndk does not support GOOGLE_THREAD_LOCAL keyword so we use a custom thread - // local message_base class we implemented. + // local storage class we implemented. // iOS also does not support the GOOGLE_THREAD_LOCAL keyword. static ThreadCache& thread_cache(); #elif defined(PROTOBUF_USE_DLLS) diff --git a/include/google/protobuf/arenastring.h b/include/google/protobuf/arenastring.h index 18400d2..122f391 100644 --- a/include/google/protobuf/arenastring.h +++ b/include/google/protobuf/arenastring.h @@ -206,7 +206,7 @@ struct PROTOBUF_EXPORT ArenaStringPtr { #endif } - // Frees message_base (if not on an arena). + // Frees storage (if not on an arena). inline void Destroy(const ::std::string* default_value, Arena* arena) { if (arena == NULL && ptr_ != default_value) { delete ptr_; diff --git a/include/google/protobuf/io/coded_stream.h b/include/google/protobuf/io/coded_stream.h index 5f98119..5f9feb8 100644 --- a/include/google/protobuf/io/coded_stream.h +++ b/include/google/protobuf/io/coded_stream.h @@ -1219,7 +1219,7 @@ class PROTOBUF_EXPORT CodedOutputStream { // Note that this is *not* canonical across languages. It is also unstable // across different builds with intervening message definition changes, due to // unknown fields. Users who need canonical serialization (e.g. persistent - // message_base in a canonical form, fingerprinting) should define their own + // storage in a canonical form, fingerprinting) should define their own // canonicalization specification and implement the serializer using // reflection APIs rather than relying on this API. void SetSerializationDeterministic(bool value) { diff --git a/include/google/protobuf/map_field_inl.h b/include/google/protobuf/map_field_inl.h index 1e6555e..7baaa5f 100644 --- a/include/google/protobuf/map_field_inl.h +++ b/include/google/protobuf/map_field_inl.h @@ -323,7 +323,7 @@ void MapField::iterator it = repeated_field->begin(); it != repeated_field->end(); ++it) { - // Cast is needed because Map's api and internal message_base is different when + // Cast is needed because Map's api and internal storage is different when // value is enum. For enum, we cannot cast an int to enum. Thus, we have to // copy value. For other types, they have same exposed api type and internal // stored type. We should not introduce value copy for them. We achieve this diff --git a/include/google/protobuf/metadata_lite.h b/include/google/protobuf/metadata_lite.h index 3ff8241..781a1f5 100644 --- a/include/google/protobuf/metadata_lite.h +++ b/include/google/protobuf/metadata_lite.h @@ -50,7 +50,7 @@ namespace internal { // uses a tagged pointer to either store the Arena pointer, if there are no // unknown fields, or a pointer to a block of memory with both the Arena pointer // and the UnknownFieldSet, if there are unknown fields. This optimization -// allows for "zero-overhead" message_base of the Arena pointer, relative to the +// allows for "zero-overhead" storage of the Arena pointer, relative to the // above baseline implementation. // // The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to diff --git a/include/google/protobuf/repeated_field.h b/include/google/protobuf/repeated_field.h index d2d9763..fd01a66 100644 --- a/include/google/protobuf/repeated_field.h +++ b/include/google/protobuf/repeated_field.h @@ -343,7 +343,7 @@ class RepeatedField final { static const size_t kRepHeaderSize; // If total_size_ == 0 this points to an Arena otherwise it points to the - // elements member of a Rep struct. Using this invariant allows the message_base of + // elements member of a Rep struct. Using this invariant allows the storage of // the arena pointer without an extra allocation in the constructor. void* arena_or_elements_; @@ -380,7 +380,7 @@ class RepeatedField final { // Copy the elements of |from| into |to|. void CopyArray(Element* to, const Element* from, int size); - // Internal helper to delete all elements and deallocate the message_base. + // Internal helper to delete all elements and deallocate the storage. // If Element has a trivial destructor (for example, if it's a fundamental // type, like int32), the loop will be removed by the optimizer. void InternalDeallocate(Rep* rep, int size) { @@ -1571,7 +1571,7 @@ void RepeatedField::Reserve(int new_size) { arena_or_elements_ = new_rep->elements; // Invoke placement-new on newly allocated elements. We shouldn't have to do // this, since Element is supposed to be POD, but a previous version of this - // code allocated message_base with "new Element[size]" and some code uses + // code allocated storage with "new Element[size]" and some code uses // RepeatedField with non-POD types, relying on constructor invocation. If // Element has a trivial constructor (e.g., int32), gcc (tested with -O2) // completely removes this loop because the loop body is empty, so this has no diff --git a/include/google/protobuf/stubs/map_util.h b/include/google/protobuf/stubs/map_util.h index ca98fef..24e098a 100644 --- a/include/google/protobuf/stubs/map_util.h +++ b/include/google/protobuf/stubs/map_util.h @@ -63,7 +63,7 @@ template struct RemoveConst : RemoveConst {}; // operator[] for lookup is discouraged for several reasons: // * It has a side-effect of inserting missing keys // * It is not thread-safe (even when it is not inserting, it can still -// choose to resize the underlying message_base) +// choose to resize the underlying storage) // * It invalidates iterators (when it chooses to resize) // * It default constructs a value object even if it doesn't need to // diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h index 9b5e533..005a0c0 100644 --- a/include/gtest/internal/gtest-port.h +++ b/include/gtest/internal/gtest-port.h @@ -1503,7 +1503,7 @@ class ThreadWithParam : public ThreadWithParamBase { ThreadWithParam& operator=(const ThreadWithParam&) = delete; }; -// Implements thread-local message_base on Windows systems. +// Implements thread-local storage on Windows systems. // // // Thread 1 // ThreadLocal tl(100); // 100 is the default value for each thread. @@ -1724,7 +1724,7 @@ extern "C" inline void DeleteThreadLocalValue(void* value_holder) { delete static_cast(value_holder); } -// Implements thread-local message_base on pthreads-based systems. +// Implements thread-local storage on pthreads-based systems. template class GTEST_API_ ThreadLocal { public: diff --git a/include/ini/SimpleIni.h b/include/ini/SimpleIni.h index 36565a5..39fcd73 100644 --- a/include/ini/SimpleIni.h +++ b/include/ini/SimpleIni.h @@ -423,7 +423,7 @@ public: #endif // SI_SUPPORT_IOSTREAMS /** Characterset conversion utility class to convert strings to the - same format as is used for the message_base. + same format as is used for the storage. */ class Converter : private SI_CONVERTER { public: @@ -480,14 +480,14 @@ public: /*-----------------------------------------------------------------------*/ /** @{ @name Settings */ - /** Set the message_base format of the INI data. This affects both the loading + /** Set the storage format of the INI data. This affects both the loading and saving of the INI data using all of the Load/Save API functions. This value cannot be changed after any INI data has been loaded. If the file is not set to Unicode (UTF-8), then the data encoding is assumed to be the OS native encoding. This encoding is the system locale on Linux/Unix and the legacy MBCS encoding on Windows NT/2K/XP. - If the message_base format is set to Unicode then the file will be loaded + If the storage format is set to Unicode then the file will be loaded as UTF-8 encoded data regardless of the native file encoding. If SI_CHAR == char then all of the char* parameters take and return UTF-8 encoded data regardless of the system locale. @@ -498,7 +498,7 @@ public: if (!m_pData) m_bStoreIsUtf8 = a_bIsUtf8; } - /** Get the message_base format of the INI data. */ + /** Get the storage format of the INI data. */ bool IsUnicode() const { return m_bStoreIsUtf8; } /** Should multiple identical keys be permitted in the file. If set to false @@ -523,7 +523,7 @@ public: m_bAllowMultiKey = a_bAllowMultiKey; } - /** Get the message_base format of the INI data. */ + /** Get the storage format of the INI data. */ bool IsMultiKey() const { return m_bAllowMultiKey; } /** Should data values be permitted to span multiple lines in the file. If @@ -2904,10 +2904,10 @@ public: } /** Calculate the number of SI_CHAR required for converting the input - * from the message_base format. The message_base format is always UTF-8 or MBCS. + * from the storage format. The storage format is always UTF-8 or MBCS. * - * @param a_pInputData Data in message_base format to be converted to SI_CHAR. - * @param a_uInputDataLen Length of message_base format data in bytes. This + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This * must be the actual length of the data, including * NULL byte if NULL terminated string is required. * @return Number of SI_CHAR required by the string when @@ -2927,11 +2927,11 @@ public: return a_uInputDataLen; } - /** Convert the input string from the message_base format to SI_CHAR. - * The message_base format is always UTF-8 or MBCS. + /** Convert the input string from the storage format to SI_CHAR. + * The storage format is always UTF-8 or MBCS. * - * @param a_pInputData Data in message_base format to be converted to SI_CHAR. - * @param a_uInputDataLen Length of message_base format data in bytes. This + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This * must be the actual length of the data, including * NULL byte if NULL terminated string is required. * @param a_pOutputData Pointer to the output buffer to received the @@ -2954,13 +2954,13 @@ public: return true; } - /** Calculate the number of char required by the message_base format of this - * data. The message_base format is always UTF-8 or MBCS. + /** Calculate the number of char required by the storage format of this + * data. The storage format is always UTF-8 or MBCS. * * @param a_pInputData NULL terminated string to calculate the number of - * bytes required to be converted to message_base format. + * bytes required to be converted to storage format. * @return Number of bytes required by the string when - * converted to message_base format. This size always + * converted to storage format. This size always * includes space for the terminating NULL character. * @return -1 cast to size_t on a conversion error. */ @@ -2971,8 +2971,8 @@ public: return strlen((const char *)a_pInputData) + 1; } - /** Convert the input string to the message_base format of this data. - * The message_base format is always UTF-8 or MBCS. + /** Convert the input string to the storage format of this data. + * The storage format is always UTF-8 or MBCS. * * @param a_pInputData NULL terminated source string to convert. All of * the data will be converted including the @@ -3033,10 +3033,10 @@ public: } /** Calculate the number of SI_CHAR required for converting the input - * from the message_base format. The message_base format is always UTF-8 or MBCS. + * from the storage format. The storage format is always UTF-8 or MBCS. * - * @param a_pInputData Data in message_base format to be converted to SI_CHAR. - * @param a_uInputDataLen Length of message_base format data in bytes. This + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This * must be the actual length of the data, including * NULL byte if NULL terminated string is required. * @return Number of SI_CHAR required by the string when @@ -3069,11 +3069,11 @@ public: #endif } - /** Convert the input string from the message_base format to SI_CHAR. - * The message_base format is always UTF-8 or MBCS. + /** Convert the input string from the storage format to SI_CHAR. + * The storage format is always UTF-8 or MBCS. * - * @param a_pInputData Data in message_base format to be converted to SI_CHAR. - * @param a_uInputDataLen Length of message_base format data in bytes. This + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This * must be the actual length of the data, including * NULL byte if NULL terminated string is required. * @param a_pOutputData Pointer to the output buffer to received the @@ -3119,13 +3119,13 @@ public: return retval != (size_t)(-1); } - /** Calculate the number of char required by the message_base format of this - * data. The message_base format is always UTF-8 or MBCS. + /** Calculate the number of char required by the storage format of this + * data. The storage format is always UTF-8 or MBCS. * * @param a_pInputData NULL terminated string to calculate the number of - * bytes required to be converted to message_base format. + * bytes required to be converted to storage format. * @return Number of bytes required by the string when - * converted to message_base format. This size always + * converted to storage format. This size always * includes space for the terminating NULL character. * @return -1 cast to size_t on a conversion error. */ @@ -3149,8 +3149,8 @@ public: } } - /** Convert the input string to the message_base format of this data. - * The message_base format is always UTF-8 or MBCS. + /** Convert the input string to the storage format of this data. + * The storage format is always UTF-8 or MBCS. * * @param a_pInputData NULL terminated source string to convert. All of * the data will be converted including the @@ -3244,10 +3244,10 @@ public: ~SI_ConvertW() { if (m_pConverter) ucnv_close(m_pConverter); } /** Calculate the number of UChar required for converting the input - * from the message_base format. The message_base format is always UTF-8 or MBCS. + * from the storage format. The storage format is always UTF-8 or MBCS. * - * @param a_pInputData Data in message_base format to be converted to UChar. - * @param a_uInputDataLen Length of message_base format data in bytes. This + * @param a_pInputData Data in storage format to be converted to UChar. + * @param a_uInputDataLen Length of storage format data in bytes. This * must be the actual length of the data, including * NULL byte if NULL terminated string is required. * @return Number of UChar required by the string when @@ -3282,11 +3282,11 @@ public: return (size_t) nLen; } - /** Convert the input string from the message_base format to UChar. - * The message_base format is always UTF-8 or MBCS. + /** Convert the input string from the storage format to UChar. + * The storage format is always UTF-8 or MBCS. * - * @param a_pInputData Data in message_base format to be converted to UChar. - * @param a_uInputDataLen Length of message_base format data in bytes. This + * @param a_pInputData Data in storage format to be converted to UChar. + * @param a_uInputDataLen Length of storage format data in bytes. This * must be the actual length of the data, including * NULL byte if NULL terminated string is required. * @param a_pOutputData Pointer to the output buffer to received the @@ -3322,13 +3322,13 @@ public: return true; } - /** Calculate the number of char required by the message_base format of this - * data. The message_base format is always UTF-8 or MBCS. + /** Calculate the number of char required by the storage format of this + * data. The storage format is always UTF-8 or MBCS. * * @param a_pInputData NULL terminated string to calculate the number of - * bytes required to be converted to message_base format. + * bytes required to be converted to storage format. * @return Number of bytes required by the string when - * converted to message_base format. This size always + * converted to storage format. This size always * includes space for the terminating NULL character. * @return -1 cast to size_t on a conversion error. */ @@ -3355,8 +3355,8 @@ public: return (size_t) nLen + 1; } - /** Convert the input string to the message_base format of this data. - * The message_base format is always UTF-8 or MBCS. + /** Convert the input string to the storage format of this data. + * The storage format is always UTF-8 or MBCS. * * @param a_pInputData NULL terminated source string to convert. All of * the data will be converted including the @@ -3465,10 +3465,10 @@ public: } /** Calculate the number of SI_CHAR required for converting the input - * from the message_base format. The message_base format is always UTF-8 or MBCS. + * from the storage format. The storage format is always UTF-8 or MBCS. * - * @param a_pInputData Data in message_base format to be converted to SI_CHAR. - * @param a_uInputDataLen Length of message_base format data in bytes. This + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This * must be the actual length of the data, including * NULL byte if NULL terminated string is required. * @return Number of SI_CHAR required by the string when @@ -3490,11 +3490,11 @@ public: return (size_t)(retval > 0 ? retval : -1); } - /** Convert the input string from the message_base format to SI_CHAR. - * The message_base format is always UTF-8 or MBCS. + /** Convert the input string from the storage format to SI_CHAR. + * The storage format is always UTF-8 or MBCS. * - * @param a_pInputData Data in message_base format to be converted to SI_CHAR. - * @param a_uInputDataLen Length of message_base format data in bytes. This + * @param a_pInputData Data in storage format to be converted to SI_CHAR. + * @param a_uInputDataLen Length of storage format data in bytes. This * must be the actual length of the data, including * NULL byte if NULL terminated string is required. * @param a_pOutputData Pointer to the output buffer to received the @@ -3516,13 +3516,13 @@ public: return (nSize > 0); } - /** Calculate the number of char required by the message_base format of this - * data. The message_base format is always UTF-8. + /** Calculate the number of char required by the storage format of this + * data. The storage format is always UTF-8. * * @param a_pInputData NULL terminated string to calculate the number of - * bytes required to be converted to message_base format. + * bytes required to be converted to storage format. * @return Number of bytes required by the string when - * converted to message_base format. This size always + * converted to storage format. This size always * includes space for the terminating NULL character. * @return -1 cast to size_t on a conversion error. */ @@ -3536,8 +3536,8 @@ public: return (size_t) (retval > 0 ? retval : -1); } - /** Convert the input string to the message_base format of this data. - * The message_base format is always UTF-8 or MBCS. + /** Convert the input string to the storage format of this data. + * The storage format is always UTF-8 or MBCS. * * @param a_pInputData NULL terminated source string to convert. All of * the data will be converted including the diff --git a/include/libevent/event2/buffer.h b/include/libevent/event2/buffer.h index 783ccb1..5a76cf2 100644 --- a/include/libevent/event2/buffer.h +++ b/include/libevent/event2/buffer.h @@ -143,7 +143,7 @@ struct evbuffer_iovec { #endif /** - Allocate message_base for a new evbuffer. + Allocate storage for a new evbuffer. @return a pointer to a newly allocated evbuffer struct, or NULL if an error occurred @@ -151,7 +151,7 @@ struct evbuffer_iovec { EVENT2_EXPORT_SYMBOL struct evbuffer *evbuffer_new(void); /** - Deallocate message_base for an evbuffer. + Deallocate storage for an evbuffer. @param buf pointer to the evbuffer to be freed */ diff --git a/include/libevent/event2/bufferevent.h b/include/libevent/event2/bufferevent.h index b47342c..a50944f 100644 --- a/include/libevent/event2/bufferevent.h +++ b/include/libevent/event2/bufferevent.h @@ -316,7 +316,7 @@ EVENT2_EXPORT_SYMBOL int bufferevent_get_priority(const struct bufferevent *bufev); /** - Deallocate the message_base associated with a bufferevent structure. + Deallocate the storage associated with a bufferevent structure. If there is pending data to write on the bufferevent, it probably won't be flushed before the bufferevent is freed. @@ -820,7 +820,7 @@ struct ev_token_bucket_cfg *ev_token_bucket_cfg_new( size_t write_rate, size_t write_burst, const struct timeval *tick_len); -/** Free all message_base held in 'cfg'. +/** Free all storage held in 'cfg'. Note: 'cfg' is not currently reference-counted; it is not safe to free it until no bufferevent is using it. diff --git a/include/libevent/event2/thread.h b/include/libevent/event2/thread.h index b8946a1..481a02f 100644 --- a/include/libevent/event2/thread.h +++ b/include/libevent/event2/thread.h @@ -107,7 +107,7 @@ struct evthread_lock_callbacks { /** Function to allocate and initialize new lock of type 'locktype'. * Returns NULL on failure. */ void *(*alloc)(unsigned locktype); - /** Funtion to release all message_base held in 'lock', which was created + /** Funtion to release all storage held in 'lock', which was created * with type 'locktype'. */ void (*free)(void *lock, unsigned locktype); /** Acquire an already-allocated lock at 'lock' with mode 'mode'. diff --git a/include/libevent/event2/util.h b/include/libevent/event2/util.h index 03e1694..60ff4cc 100644 --- a/include/libevent/event2/util.h +++ b/include/libevent/event2/util.h @@ -808,7 +808,7 @@ EVENT2_EXPORT_SYMBOL int evutil_getaddrinfo(const char *nodename, const char *servname, const struct evutil_addrinfo *hints_in, struct evutil_addrinfo **res); -/** Release message_base allocated by evutil_getaddrinfo or evdns_getaddrinfo. */ +/** Release storage allocated by evutil_getaddrinfo or evdns_getaddrinfo. */ EVENT2_EXPORT_SYMBOL void evutil_freeaddrinfo(struct evutil_addrinfo *ai); diff --git a/include/mysql++/mysql/mysql_com.h b/include/mysql++/mysql/mysql_com.h index 3b55f79..a924041 100644 --- a/include/mysql++/mysql/mysql_com.h +++ b/include/mysql++/mysql/mysql_com.h @@ -181,7 +181,7 @@ */ #define FIELD_IN_ADD_INDEX (1 << 20) #define FIELD_IS_RENAMED (1 << 21) /**< Intern: Field is being renamed */ -#define FIELD_FLAGS_STORAGE_MEDIA 22 /**< Field message_base media, bit 22-23 */ +#define FIELD_FLAGS_STORAGE_MEDIA 22 /**< Field storage media, bit 22-23 */ #define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA) #define FIELD_FLAGS_COLUMN_FORMAT 24 /**< Field column format, bit 24-25 */ #define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT) @@ -232,7 +232,7 @@ 128 /**< Remove all bin logs in the index \ and truncate the index, RESET MASTER */ #define REFRESH_ERROR_LOG 256 /**< Rotate only the error log */ -#define REFRESH_ENGINE_LOG 512 /**< Flush all message_base engine logs */ +#define REFRESH_ENGINE_LOG 512 /**< Flush all storage engine logs */ #define REFRESH_BINARY_LOG 1024 /**< Flush the binary log */ #define REFRESH_RELAY_LOG 2048 /**< Flush the relay log */ #define REFRESH_GENERAL_LOG 4096 /**< Flush the general log */ @@ -1009,9 +1009,9 @@ enum mysql_enum_shutdown_level { SHUTDOWN_WAIT_TRANSACTIONS = MYSQL_SHUTDOWN_KILLABLE_TRANS, /** Wait for existing updates to finish (=> no partial MyISAM update) */ SHUTDOWN_WAIT_UPDATES = MYSQL_SHUTDOWN_KILLABLE_UPDATE, - /** Flush InnoDB buffers and other message_base engines' buffers*/ + /** Flush InnoDB buffers and other storage engines' buffers*/ SHUTDOWN_WAIT_ALL_BUFFERS = (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1), - /** Don't flush InnoDB buffers, flush other message_base engines' buffers*/ + /** Don't flush InnoDB buffers, flush other storage engines' buffers*/ SHUTDOWN_WAIT_CRITICAL_BUFFERS = (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1, /** Query level of the KILL command */ KILL_QUERY = 254, diff --git a/include/mysql++/transaction.h b/include/mysql++/transaction.h index 1b2e7bf..d5fbb82 100644 --- a/include/mysql++/transaction.h +++ b/include/mysql++/transaction.h @@ -106,7 +106,7 @@ public: /// This commits all updates to the database using the connection /// we were created with since this object was created. This is a /// no-op if the table isn't stored using a transaction-aware - /// message_base engine. See CREATE TABLE in the MySQL manual for + /// storage engine. See CREATE TABLE in the MySQL manual for /// details. void commit(); @@ -114,7 +114,7 @@ public: /// /// This abandons all SQL statements made on the connection since /// this object was created. This only works on tables stored using - /// a transaction-aware message_base engine. See CREATE TABLE in the + /// a transaction-aware storage engine. See CREATE TABLE in the /// MySQL manual for details. void rollback(); diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 434fa21..2cd9a70 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -1231,7 +1231,7 @@ public: RAPIDJSON_ASSERT(false); // see above note #if RAPIDJSON_HAS_CXX11 - // Use thread-local message_base to prevent races between threads. + // Use thread-local storage to prevent races between threads. // Use static buffer and placement-new to prevent destruction, with // alignas() to ensure proper alignment. alignas(GenericValue) thread_local static char buffer[sizeof(GenericValue)]; @@ -2490,7 +2490,7 @@ typedef GenericValue > Value; //! A document for parsing JSON text as DOM. /*! \note implements Handler concept - \tparam Encoding Encoding for both parsing and string message_base. + \tparam Encoding Encoding for both parsing and string storage. \tparam Allocator Allocator for allocating memory for the DOM \tparam StackAllocator Allocator for allocating memory for stack during parsing. \warning Although GenericDocument inherits from GenericValue, the API does \b not provide any virtual functions, especially no virtual destructor. To avoid memory leaks, do not \c delete a GenericDocument object via a pointer to a GenericValue. diff --git a/include/tbb/oneapi/tbb/cache_aligned_allocator.h b/include/tbb/oneapi/tbb/cache_aligned_allocator.h index d17cb47..0ff3972 100644 --- a/include/tbb/oneapi/tbb/cache_aligned_allocator.h +++ b/include/tbb/oneapi/tbb/cache_aligned_allocator.h @@ -128,7 +128,7 @@ private: // Round up to the next cache line (align the base address) std::uintptr_t result = (base + cache_line_alignment) & ~(cache_line_alignment - 1); __TBB_ASSERT((result - base) >= sizeof(std::uintptr_t), "Can`t store a base pointer to the header"); - __TBB_ASSERT(space - (result - base) >= bytes, "Not enough space for the message_base"); + __TBB_ASSERT(space - (result - base) >= bytes, "Not enough space for the storage"); // Record where block actually starts. (reinterpret_cast(result))[-1] = base; diff --git a/include/tbb/oneapi/tbb/collaborative_call_once.h b/include/tbb/oneapi/tbb/collaborative_call_once.h index 65dc8da..db082f8 100644 --- a/include/tbb/oneapi/tbb/collaborative_call_once.h +++ b/include/tbb/oneapi/tbb/collaborative_call_once.h @@ -95,7 +95,7 @@ public: template void run_once(F&& f) { - __TBB_ASSERT(!m_is_ready.load(std::memory_order_relaxed), "message_base with task_arena and wait_context is already initialized"); + __TBB_ASSERT(!m_is_ready.load(std::memory_order_relaxed), "storage with task_arena and wait_context is already initialized"); // Initialize internal state new(&m_storage) storage_t(); m_storage.m_arena.execute([&] { diff --git a/include/tbb/oneapi/tbb/combinable.h b/include/tbb/oneapi/tbb/combinable.h index c5cc172..b676a30 100644 --- a/include/tbb/oneapi/tbb/combinable.h +++ b/include/tbb/oneapi/tbb/combinable.h @@ -27,7 +27,7 @@ namespace detail { namespace d1 { /** \name combinable **/ //@{ -//! Thread-local message_base with optional reduction +//! Thread-local storage with optional reduction /** @ingroup containers */ template class combinable { diff --git a/include/tbb/oneapi/tbb/concurrent_lru_cache.h b/include/tbb/oneapi/tbb/concurrent_lru_cache.h index 8616c31..29ee3bd 100644 --- a/include/tbb/oneapi/tbb/concurrent_lru_cache.h +++ b/include/tbb/oneapi/tbb/concurrent_lru_cache.h @@ -83,7 +83,7 @@ private: value_function_type my_value_function; aggregator_type my_aggregator; - storage_map_type my_storage_map; // message_base map for used objects + storage_map_type my_storage_map; // storage map for used objects history_list_type my_history_list; // history list for unused objects const std::size_t my_history_list_capacity; // history list's allowed capacity @@ -186,7 +186,7 @@ private: }; //----------------------------------------------------------------------------- -// Value type for message_base map in concurrent LRU cache +// Value type for storage map in concurrent LRU cache //----------------------------------------------------------------------------- template diff --git a/include/tbb/oneapi/tbb/enumerable_thread_specific.h b/include/tbb/oneapi/tbb/enumerable_thread_specific.h index d7b1ff0..34bcab6 100644 --- a/include/tbb/oneapi/tbb/enumerable_thread_specific.h +++ b/include/tbb/oneapi/tbb/enumerable_thread_specific.h @@ -651,7 +651,7 @@ struct construct_by_args: no_assign { construct_by_args( P&& ... args ) : pack(std::forward

(args)...) {} }; -// message_base for initialization function pointer +// storage for initialization function pointer // TODO: consider removing the template parameter T here and in callback_leaf class callback_base { public: @@ -734,7 +734,7 @@ template using is_callable_no_args = supportsets_base::table_swap(other);