修改了 message system
This commit is contained in:
parent
a764f9fcab
commit
5b12450a56
@ -161,12 +161,12 @@ class MONGOCXX_API create_collection_deprecated {
|
|||||||
const stdx::optional<std::int64_t>& size() const;
|
const stdx::optional<std::int64_t>& 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
|
/// @param storage_engine_opts
|
||||||
/// Configuration options specific to the message_base engine.
|
/// Configuration options specific to the storage engine.
|
||||||
///
|
///
|
||||||
/// @return
|
/// @return
|
||||||
/// A reference to the object on which this member function is being called. This facilitates
|
/// 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);
|
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
|
/// @return
|
||||||
/// Configuration options specific to the message_base engine.
|
/// Configuration options specific to the storage engine.
|
||||||
///
|
///
|
||||||
const stdx::optional<bsoncxx::document::view_or_value>& storage_engine() const;
|
const stdx::optional<bsoncxx::document::view_or_value>& storage_engine() const;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ namespace options {
|
|||||||
class MONGOCXX_API index {
|
class MONGOCXX_API index {
|
||||||
public:
|
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 {
|
class MONGOCXX_API base_storage_options {
|
||||||
public:
|
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 {
|
class MONGOCXX_API wiredtiger_storage_options final : public base_storage_options {
|
||||||
public:
|
public:
|
||||||
@ -216,11 +216,11 @@ class MONGOCXX_API index {
|
|||||||
const stdx::optional<bool>& sparse() const;
|
const stdx::optional<bool>& 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.
|
/// the index.
|
||||||
///
|
///
|
||||||
/// @param storage_options
|
/// @param storage_options
|
||||||
/// The message_base engine options for the index.
|
/// The storage engine options for the index.
|
||||||
///
|
///
|
||||||
/// @return
|
/// @return
|
||||||
/// A reference to the object on which this member function is being called. This facilitates
|
/// 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<base_storage_options> storage_options);
|
index& storage_options(std::unique_ptr<base_storage_options> 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.
|
/// engine options for the index.
|
||||||
///
|
///
|
||||||
/// @param storage_options
|
/// @param storage_options
|
||||||
/// The message_base engine options for the index.
|
/// The storage engine options for the index.
|
||||||
///
|
///
|
||||||
index& storage_options(std::unique_ptr<wiredtiger_storage_options> storage_options);
|
index& storage_options(std::unique_ptr<wiredtiger_storage_options> storage_options);
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class uri;
|
|||||||
/// collection level. The read concern can also be provided via connection string, and will be
|
/// 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.
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
/// a single document. Note that writes must be made with majority write concern in order for reads
|
||||||
/// to be linearizable.
|
/// to be linearizable.
|
||||||
///
|
///
|
||||||
|
@ -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) :
|
uint64_t messageId, time_t time) :
|
||||||
Mph(type),
|
Mph(type),
|
||||||
MsgData(subType, messageId, time) {
|
MsgData(messageId, time) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string IMDataPacket::packet() {
|
std::string IMDataPacket::packet() {
|
||||||
|
@ -12,13 +12,35 @@
|
|||||||
|
|
||||||
class IMDataPacket : public Mph, MsgData {
|
class IMDataPacket : public Mph, MsgData {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息包
|
||||||
|
* @param type 包类型
|
||||||
|
* @param data protobuf 定义的 消息包类型
|
||||||
|
*/
|
||||||
IMDataPacket(mp::MP_TYPE type, mp::im::msg_data* data);
|
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,
|
IMDataPacket(mp::MP_TYPE type, mp::MP_SUB_TYPE subType,
|
||||||
mp::MP_SUB_TYPE sessionType, uint64_t messageId,
|
mp::MP_SUB_TYPE sessionType, uint64_t messageId,
|
||||||
time_t time, uint64_t account, const std::string &imMsgData);
|
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);
|
uint64_t messageId, time_t time);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -29,6 +29,12 @@ public:
|
|||||||
data->set_time(time);
|
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() {
|
virtual ~MsgData() {
|
||||||
delete data;
|
delete data;
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,8 @@ enum MP_SUB_TYPE {
|
|||||||
|
|
||||||
MP_ADD_CHECK = 80; // 需要回答问题的好友/群组 验证问题
|
MP_ADD_CHECK = 80; // 需要回答问题的好友/群组 验证问题
|
||||||
|
|
||||||
|
MP_TYPE_NULL = 100; // 类型无意义 用于填充
|
||||||
|
|
||||||
///***********************************************************************************///
|
///***********************************************************************************///
|
||||||
|
|
||||||
/// 200+ IM ***********************************************************************************///
|
/// 200+ IM ***********************************************************************************///
|
||||||
|
@ -16,6 +16,23 @@ session::session() {
|
|||||||
printf("timing end\n");
|
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
|
/// curr mem user curd user session
|
||||||
void session::add_user(mp::sri* sri, std::shared_ptr<agreement_request>& request) {
|
void session::add_user(mp::sri* sri, std::shared_ptr<agreement_request>& request) {
|
||||||
if (sri->subcommand() == mp::MP_LOGIN_SUCCESS) {
|
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) {
|
void session::set_session(bufferevent* bev, const std::string &session_key, const std::string &session_value) {
|
||||||
printf("code: %s\n", session_value.c_str());
|
printf("code: %s\n", session_value.c_str());
|
||||||
@ -198,3 +216,5 @@ std::optional<userinfo*> session::find_user(uint64_t account) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,10 +25,23 @@ struct bev_key {
|
|||||||
std::string value;
|
std::string value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum session_build_type {
|
||||||
|
SESSION_SUPPORT_USER = 0,
|
||||||
|
SESSION_SUPPORT_SESSION = 1,
|
||||||
|
SESSION_SUPPORT_ALL = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class session {
|
class session {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* 空构造是 全部支持
|
||||||
|
*/
|
||||||
session();
|
session();
|
||||||
|
/**
|
||||||
|
* 选择支持
|
||||||
|
*/
|
||||||
|
session(session_build_type type);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 添加用户
|
// 添加用户
|
||||||
@ -45,6 +58,7 @@ public:
|
|||||||
bool is_user(const std::string& account);
|
bool is_user(const std::string& account);
|
||||||
// 是否有这个用户
|
// 是否有这个用户
|
||||||
bool is_user(uint64_t account);
|
bool is_user(uint64_t account);
|
||||||
|
|
||||||
// 初始化 session
|
// 初始化 session
|
||||||
void init_session(bufferevent* bev);
|
void init_session(bufferevent* bev);
|
||||||
// 设置 session
|
// 设置 session
|
||||||
|
@ -7,6 +7,7 @@ aux_source_directory(db/po DIR_WORKS_DB_PO)
|
|||||||
|
|
||||||
include_directories(../mmm)
|
include_directories(../mmm)
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/MDB/imm_mysqldb)
|
include_directories(${CMAKE_SOURCE_DIR}/MDB/imm_mysqldb)
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/MessageSystem)
|
||||||
|
|
||||||
add_library(works
|
add_library(works
|
||||||
${DIR_WORKS_CONTROLLER}
|
${DIR_WORKS_CONTROLLER}
|
||||||
|
@ -3,14 +3,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "IMController.h"
|
#include "IMController.h"
|
||||||
|
#include "message_push/MessageMgr.h"
|
||||||
|
|
||||||
void IMController::run(std::shared_ptr<agreement_request> request, std::shared_ptr<agreement_response> response) {
|
void IMController::run(std::shared_ptr<agreement_request> request, std::shared_ptr<agreement_response> response) {
|
||||||
// msg push 储存库内 正常会话 要同步库 储存库
|
MessageMgr();
|
||||||
if (request->m_mph->mp_type() == mp::MP_IM_PUSH_MSG) {
|
|
||||||
|
|
||||||
}
|
|
||||||
// 传来 im msg 临时会话 消息包本体 要同步库
|
|
||||||
else if (request->m_mph->mp_type() == mp::MP_IM_MSG) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,28 @@
|
|||||||
project(MessageSystem)
|
project(MessageSystem)
|
||||||
|
|
||||||
aux_source_directory(message_push PUSH)
|
aux_source_directory(message_push PUSH)
|
||||||
aux_source_directory(message_base BASE)
|
aux_source_directory(message_push/online ONLINE)
|
||||||
aux_source_directory(message_pull PULL)
|
aux_source_directory(message_push/offline OFFLINE)
|
||||||
aux_source_directory(timeline_safe SAFE_QUEUE)
|
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}/MP)
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/MDB/imm_mongodb)
|
include_directories(${CMAKE_SOURCE_DIR}/MDB/imm_mongodb)
|
||||||
|
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/MessageSystem)
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/MS/mmm)
|
||||||
|
|
||||||
add_library(MessageSystem
|
add_library(MessageSystem
|
||||||
${PUSH}
|
${PUSH}
|
||||||
${BASE}
|
${ONLINE}
|
||||||
|
${OFFLINE}
|
||||||
|
${STORAGE}
|
||||||
${PULL}
|
${PULL}
|
||||||
${SAFE_QUEUE}
|
${SAFE_QUEUE}
|
||||||
|
${BASE}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(MessageSystem
|
target_link_libraries(MessageSystem
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by dongl on 23-5-29.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "Storage.h"
|
|
||||||
#include "template/MsgTemplate.h"
|
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
MSG::Storage::Storage(TimeLine<StorageMsg *> *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<StorageMsg *>();
|
|
||||||
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<void()> 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by dongl on 23-7-1.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "Syn.h"
|
|
@ -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
|
|
@ -3,8 +3,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "db_base.h"
|
#include "db_base.h"
|
||||||
#include <mongocxx/instance.hpp>
|
#include "mongocxx/instance.hpp"
|
||||||
#include <mongocxx/uri.hpp>
|
#include "mongocxx/uri.hpp"
|
||||||
|
|
||||||
|
|
||||||
db_base::db_base() {
|
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");
|
mongocxx::uri uri("mongodb://user_session:Aa316216@124.221.152.192:27017/?authSource=im_session");
|
||||||
pool = new mongocxx::pool(uri);
|
pool = new mongocxx::pool(uri);
|
||||||
}
|
}
|
||||||
|
db_base::~db_base() {
|
||||||
|
delete pool;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mongocxx::pool::entry db_base::acquire() {
|
mongocxx::pool::entry db_base::acquire() {
|
||||||
return pool->acquire();
|
return pool->acquire();
|
||||||
@ -33,3 +37,4 @@ mongocxx::collection db_base::hit_db_coll(const std::string& db_name, const std:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
#ifndef IM2_DB_BASE_H
|
#ifndef IM2_DB_BASE_H
|
||||||
#define IM2_DB_BASE_H
|
#define IM2_DB_BASE_H
|
||||||
|
|
||||||
#include <mongocxx/pool.hpp>
|
#include "mongocxx/pool.hpp"
|
||||||
#include <mongocxx/stdx.hpp>
|
#include "mongocxx/stdx.hpp"
|
||||||
#include <bsoncxx/stdx/optional.hpp>
|
#include "bsoncxx/stdx/optional.hpp"
|
||||||
#include <mongocxx/client.hpp>
|
#include "mongocxx/client.hpp"
|
||||||
|
|
||||||
using bsoncxx::builder::basic::kvp;
|
using bsoncxx::builder::basic::kvp;
|
||||||
using bsoncxx::builder::basic::make_array;
|
using bsoncxx::builder::basic::make_array;
|
||||||
@ -17,6 +17,9 @@ using bsoncxx::builder::basic::make_document;
|
|||||||
class db_base {
|
class db_base {
|
||||||
public:
|
public:
|
||||||
db_base();
|
db_base();
|
||||||
|
|
||||||
|
virtual ~db_base();
|
||||||
|
|
||||||
mongocxx::pool::entry acquire();
|
mongocxx::pool::entry acquire();
|
||||||
bsoncxx::stdx::optional<mongocxx::pool::entry> try_acquire();
|
bsoncxx::stdx::optional<mongocxx::pool::entry> try_acquire();
|
||||||
|
|
||||||
@ -24,7 +27,7 @@ public:
|
|||||||
// 命中 库 表
|
// 命中 库 表
|
||||||
mongocxx::collection hit_db_coll(const std::string& db_name, const std::string& coll);
|
mongocxx::collection hit_db_coll(const std::string& db_name, const std::string& coll);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
mongocxx::pool* pool = nullptr;
|
mongocxx::pool* pool = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
43
MessageSystem/message_push/MessageMgr.cpp
Normal file
43
MessageSystem/message_push/MessageMgr.cpp
Normal file
@ -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());
|
||||||
|
}
|
||||||
|
|
45
MessageSystem/message_push/MessageMgr.h
Normal file
45
MessageSystem/message_push/MessageMgr.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
//
|
||||||
|
// Created by dongl on 23-7-4.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef IM2_MESSAGEMGR_H
|
||||||
|
#define IM2_MESSAGEMGR_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#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
|
5
MessageSystem/message_push/offline/OfflineMessageMgr.cpp
Normal file
5
MessageSystem/message_push/offline/OfflineMessageMgr.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
//
|
||||||
|
// Created by dongl on 23-7-4.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "OfflineMessageMgr.h"
|
14
MessageSystem/message_push/offline/OfflineMessageMgr.h
Normal file
14
MessageSystem/message_push/offline/OfflineMessageMgr.h
Normal file
@ -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
|
5
MessageSystem/message_push/online/OnlineMessageMgr.cpp
Normal file
5
MessageSystem/message_push/online/OnlineMessageMgr.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
//
|
||||||
|
// Created by dongl on 23-7-4.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "OnlineMessageMgr.h"
|
17
MessageSystem/message_push/online/OnlineMessageMgr.h
Normal file
17
MessageSystem/message_push/online/OnlineMessageMgr.h
Normal file
@ -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
|
@ -2,6 +2,5 @@
|
|||||||
// Created by dongl on 23-5-17.
|
// Created by dongl on 23-5-17.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "TimeLine.h"
|
#include "SafeQueue.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
103
MessageSystem/message_safe/SafeQueue.h
Normal file
103
MessageSystem/message_safe/SafeQueue.h
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
//
|
||||||
|
// Created by dongl on 23-5-17.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef IM2_TIMELINE_H
|
||||||
|
#define IM2_SAFEQUEUE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <queue>
|
||||||
|
#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 T>
|
||||||
|
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<T>
|
||||||
|
*/
|
||||||
|
std::queue<T>& value() {
|
||||||
|
return queue;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::mutex mutex;
|
||||||
|
std::queue<T> queue;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //IM2_TIMELINE_H
|
64
MessageSystem/message_storage/Storage.cpp
Normal file
64
MessageSystem/message_storage/Storage.cpp
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
//
|
||||||
|
// Created by dongl on 23-5-29.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Storage.h"
|
||||||
|
#include "template/MsgTemplate.h"
|
||||||
|
#include "IMDataPacket.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
MSG::Storage::Storage(SafeQueue<StorageMsg *> *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<StorageMsg *>();
|
||||||
|
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<void()> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -6,24 +6,24 @@
|
|||||||
#define IM2_STORAGE_H
|
#define IM2_STORAGE_H
|
||||||
|
|
||||||
|
|
||||||
#include "db_base.h"
|
#include "message_base/db_base.h"
|
||||||
#include "../timeline_safe/TimeLine.h"
|
#include "message_safe/SafeQueue.h"
|
||||||
|
|
||||||
namespace MSG {
|
namespace MSG {
|
||||||
class Storage {
|
class Storage : db_base {
|
||||||
public:
|
public:
|
||||||
Storage(TimeLine<StorageMsg *> *timeLine, db_base* db);
|
Storage(SafeQueue<StorageMsg *> *timeLine, db_base* db);
|
||||||
Storage(std::string&& db_name, std::string&& table);
|
Storage(std::string&& db_name, std::string&& table);
|
||||||
|
|
||||||
|
virtual ~Storage();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void push(StorageMsg* msg);
|
void push(StorageMsg* msg);
|
||||||
void pull();
|
|
||||||
|
|
||||||
void storage_push_queue();
|
void storage_push_lister_queue();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
db_base* m_db = nullptr;
|
SafeQueue<StorageMsg *> * m_timeLine = nullptr;
|
||||||
TimeLine<StorageMsg *> * m_timeLine = nullptr;
|
|
||||||
|
|
||||||
std::string m_db_name, m_table;
|
std::string m_db_name, m_table;
|
||||||
};
|
};
|
43
MessageSystem/message_storage/Syn.cpp
Normal file
43
MessageSystem/message_storage/Syn.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
//
|
||||||
|
// Created by dongl on 23-7-1.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include "Syn.h"
|
||||||
|
#include "IMDataPacket.h"
|
||||||
|
|
||||||
|
MSG::Syn::Syn(SafeQueue<SynMsg *> *mTimeLine) : m_timeLine(mTimeLine) {}
|
||||||
|
|
||||||
|
MSG::Syn::Syn() : m_timeLine(new SafeQueue<SynMsg* >) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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<void(std::string&& packet)>& cb) {
|
||||||
|
std::function<void()> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
26
MessageSystem/message_storage/Syn.h
Normal file
26
MessageSystem/message_storage/Syn.h
Normal file
@ -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<SynMsg *> *mTimeLine);
|
||||||
|
explicit Syn();
|
||||||
|
virtual ~Syn();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void push(SynMsg* msg);
|
||||||
|
void syn_push_lister_queue(const std::function<void(std::string&& packet)>&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
SafeQueue<SynMsg *>* m_timeLine = nullptr;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //IM2_SYN_H
|
@ -1,55 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by dongl on 23-5-17.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef IM2_TIMELINE_H
|
|
||||||
#define IM2_TIMELINE_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <queue>
|
|
||||||
#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 T>
|
|
||||||
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<T>& value() {
|
|
||||||
return queue;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
std::mutex mutex;
|
|
||||||
std::queue<T> queue;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //IM2_TIMELINE_H
|
|
@ -9,9 +9,8 @@
|
|||||||
#include "works/db/UserFriendsDB.h"
|
#include "works/db/UserFriendsDB.h"
|
||||||
#include "works/db/UserDB.h"
|
#include "works/db/UserDB.h"
|
||||||
#include "smtp/send_email.h"
|
#include "smtp/send_email.h"
|
||||||
#include "storage/Storage.h"
|
|
||||||
#include "IMDataPacket.h"
|
#include "IMDataPacket.h"
|
||||||
#include "template/MsgTemplate.h"
|
#include "message_storage/Storage.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
@ -147,4 +146,27 @@ TEST (MP_IM_PUSH_MSG, MP_IM_PUSH_MSG_TEST) {
|
|||||||
storage->push(msg);
|
storage->push(msg);
|
||||||
|
|
||||||
sleep(10);
|
sleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(queue, queue_test) {
|
||||||
|
std::queue<int> queue;
|
||||||
|
queue.push(1);
|
||||||
|
queue.push(2);
|
||||||
|
|
||||||
|
printf("%d", *((&queue.front()) + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
|
|||||||
// the call to this method.
|
// the call to this method.
|
||||||
uint64 SpaceUsed() const { return impl_.SpaceUsed(); }
|
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().
|
// registered with OwnDestructor() and freeing objects registered with Own().
|
||||||
// Any objects allocated on this arena are unusable after this call. It also
|
// 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
|
// returns the total space used by the arena which is the sums of the sizes
|
||||||
|
@ -289,7 +289,7 @@ class PROTOBUF_EXPORT ArenaImpl {
|
|||||||
static std::atomic<LifecycleId> lifecycle_id_generator_;
|
static std::atomic<LifecycleId> lifecycle_id_generator_;
|
||||||
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
|
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
|
||||||
// Android ndk does not support GOOGLE_THREAD_LOCAL keyword so we use a custom thread
|
// 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.
|
// iOS also does not support the GOOGLE_THREAD_LOCAL keyword.
|
||||||
static ThreadCache& thread_cache();
|
static ThreadCache& thread_cache();
|
||||||
#elif defined(PROTOBUF_USE_DLLS)
|
#elif defined(PROTOBUF_USE_DLLS)
|
||||||
|
@ -206,7 +206,7 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
|
|||||||
#endif
|
#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) {
|
inline void Destroy(const ::std::string* default_value, Arena* arena) {
|
||||||
if (arena == NULL && ptr_ != default_value) {
|
if (arena == NULL && ptr_ != default_value) {
|
||||||
delete ptr_;
|
delete ptr_;
|
||||||
|
@ -1219,7 +1219,7 @@ class PROTOBUF_EXPORT CodedOutputStream {
|
|||||||
// Note that this is *not* canonical across languages. It is also unstable
|
// Note that this is *not* canonical across languages. It is also unstable
|
||||||
// across different builds with intervening message definition changes, due to
|
// across different builds with intervening message definition changes, due to
|
||||||
// unknown fields. Users who need canonical serialization (e.g. persistent
|
// 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
|
// canonicalization specification and implement the serializer using
|
||||||
// reflection APIs rather than relying on this API.
|
// reflection APIs rather than relying on this API.
|
||||||
void SetSerializationDeterministic(bool value) {
|
void SetSerializationDeterministic(bool value) {
|
||||||
|
@ -323,7 +323,7 @@ void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
|
|||||||
for (typename RepeatedPtrField<EntryType>::iterator it =
|
for (typename RepeatedPtrField<EntryType>::iterator it =
|
||||||
repeated_field->begin();
|
repeated_field->begin();
|
||||||
it != repeated_field->end(); ++it) {
|
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
|
// 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
|
// 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
|
// stored type. We should not introduce value copy for them. We achieve this
|
||||||
|
@ -50,7 +50,7 @@ namespace internal {
|
|||||||
// uses a tagged pointer to either store the Arena pointer, if there are no
|
// 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
|
// 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
|
// 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.
|
// above baseline implementation.
|
||||||
//
|
//
|
||||||
// The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to
|
// The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to
|
||||||
|
@ -343,7 +343,7 @@ class RepeatedField final {
|
|||||||
static const size_t kRepHeaderSize;
|
static const size_t kRepHeaderSize;
|
||||||
|
|
||||||
// If total_size_ == 0 this points to an Arena otherwise it points to the
|
// 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.
|
// the arena pointer without an extra allocation in the constructor.
|
||||||
void* arena_or_elements_;
|
void* arena_or_elements_;
|
||||||
|
|
||||||
@ -380,7 +380,7 @@ class RepeatedField final {
|
|||||||
// Copy the elements of |from| into |to|.
|
// Copy the elements of |from| into |to|.
|
||||||
void CopyArray(Element* to, const Element* from, int size);
|
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
|
// If Element has a trivial destructor (for example, if it's a fundamental
|
||||||
// type, like int32), the loop will be removed by the optimizer.
|
// type, like int32), the loop will be removed by the optimizer.
|
||||||
void InternalDeallocate(Rep* rep, int size) {
|
void InternalDeallocate(Rep* rep, int size) {
|
||||||
@ -1571,7 +1571,7 @@ void RepeatedField<Element>::Reserve(int new_size) {
|
|||||||
arena_or_elements_ = new_rep->elements;
|
arena_or_elements_ = new_rep->elements;
|
||||||
// Invoke placement-new on newly allocated elements. We shouldn't have to do
|
// 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
|
// 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
|
// RepeatedField with non-POD types, relying on constructor invocation. If
|
||||||
// Element has a trivial constructor (e.g., int32), gcc (tested with -O2)
|
// 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
|
// completely removes this loop because the loop body is empty, so this has no
|
||||||
|
@ -63,7 +63,7 @@ template <class T> struct RemoveConst<const T> : RemoveConst<T> {};
|
|||||||
// operator[] for lookup is discouraged for several reasons:
|
// operator[] for lookup is discouraged for several reasons:
|
||||||
// * It has a side-effect of inserting missing keys
|
// * It has a side-effect of inserting missing keys
|
||||||
// * It is not thread-safe (even when it is not inserting, it can still
|
// * 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 invalidates iterators (when it chooses to resize)
|
||||||
// * It default constructs a value object even if it doesn't need to
|
// * It default constructs a value object even if it doesn't need to
|
||||||
//
|
//
|
||||||
|
@ -1503,7 +1503,7 @@ class ThreadWithParam : public ThreadWithParamBase {
|
|||||||
ThreadWithParam& operator=(const ThreadWithParam&) = delete;
|
ThreadWithParam& operator=(const ThreadWithParam&) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Implements thread-local message_base on Windows systems.
|
// Implements thread-local storage on Windows systems.
|
||||||
//
|
//
|
||||||
// // Thread 1
|
// // Thread 1
|
||||||
// ThreadLocal<int> tl(100); // 100 is the default value for each thread.
|
// ThreadLocal<int> 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<ThreadLocalValueHolderBase*>(value_holder);
|
delete static_cast<ThreadLocalValueHolderBase*>(value_holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements thread-local message_base on pthreads-based systems.
|
// Implements thread-local storage on pthreads-based systems.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class GTEST_API_ ThreadLocal {
|
class GTEST_API_ ThreadLocal {
|
||||||
public:
|
public:
|
||||||
|
@ -423,7 +423,7 @@ public:
|
|||||||
#endif // SI_SUPPORT_IOSTREAMS
|
#endif // SI_SUPPORT_IOSTREAMS
|
||||||
|
|
||||||
/** Characterset conversion utility class to convert strings to the
|
/** 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 {
|
class Converter : private SI_CONVERTER {
|
||||||
public:
|
public:
|
||||||
@ -480,14 +480,14 @@ public:
|
|||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/** @{ @name Settings */
|
/** @{ @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.
|
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.
|
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
|
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
|
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.
|
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
|
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
|
SI_CHAR == char then all of the char* parameters take and return UTF-8
|
||||||
encoded data regardless of the system locale.
|
encoded data regardless of the system locale.
|
||||||
@ -498,7 +498,7 @@ public:
|
|||||||
if (!m_pData) m_bStoreIsUtf8 = a_bIsUtf8;
|
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; }
|
bool IsUnicode() const { return m_bStoreIsUtf8; }
|
||||||
|
|
||||||
/** Should multiple identical keys be permitted in the file. If set to false
|
/** Should multiple identical keys be permitted in the file. If set to false
|
||||||
@ -523,7 +523,7 @@ public:
|
|||||||
m_bAllowMultiKey = a_bAllowMultiKey;
|
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; }
|
bool IsMultiKey() const { return m_bAllowMultiKey; }
|
||||||
|
|
||||||
/** Should data values be permitted to span multiple lines in the file. If
|
/** 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
|
/** 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_pInputData Data in storage format to be converted to SI_CHAR.
|
||||||
* @param a_uInputDataLen Length of message_base format data in bytes. This
|
* @param a_uInputDataLen Length of storage format data in bytes. This
|
||||||
* must be the actual length of the data, including
|
* must be the actual length of the data, including
|
||||||
* NULL byte if NULL terminated string is required.
|
* NULL byte if NULL terminated string is required.
|
||||||
* @return Number of SI_CHAR required by the string when
|
* @return Number of SI_CHAR required by the string when
|
||||||
@ -2927,11 +2927,11 @@ public:
|
|||||||
return a_uInputDataLen;
|
return a_uInputDataLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert the input string from the message_base format to SI_CHAR.
|
/** Convert the input string from the storage format to SI_CHAR.
|
||||||
* The message_base format is always UTF-8 or MBCS.
|
* 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_pInputData Data in storage format to be converted to SI_CHAR.
|
||||||
* @param a_uInputDataLen Length of message_base format data in bytes. This
|
* @param a_uInputDataLen Length of storage format data in bytes. This
|
||||||
* must be the actual length of the data, including
|
* must be the actual length of the data, including
|
||||||
* NULL byte if NULL terminated string is required.
|
* NULL byte if NULL terminated string is required.
|
||||||
* @param a_pOutputData Pointer to the output buffer to received the
|
* @param a_pOutputData Pointer to the output buffer to received the
|
||||||
@ -2954,13 +2954,13 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Calculate the number of char required by the message_base format of this
|
/** Calculate the number of char required by the storage format of this
|
||||||
* data. The message_base format is always UTF-8 or MBCS.
|
* data. The storage format is always UTF-8 or MBCS.
|
||||||
*
|
*
|
||||||
* @param a_pInputData NULL terminated string to calculate the number of
|
* @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
|
* @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.
|
* includes space for the terminating NULL character.
|
||||||
* @return -1 cast to size_t on a conversion error.
|
* @return -1 cast to size_t on a conversion error.
|
||||||
*/
|
*/
|
||||||
@ -2971,8 +2971,8 @@ public:
|
|||||||
return strlen((const char *)a_pInputData) + 1;
|
return strlen((const char *)a_pInputData) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert the input string to the message_base format of this data.
|
/** Convert the input string to the storage format of this data.
|
||||||
* The message_base format is always UTF-8 or MBCS.
|
* The storage format is always UTF-8 or MBCS.
|
||||||
*
|
*
|
||||||
* @param a_pInputData NULL terminated source string to convert. All of
|
* @param a_pInputData NULL terminated source string to convert. All of
|
||||||
* the data will be converted including the
|
* the data will be converted including the
|
||||||
@ -3033,10 +3033,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Calculate the number of SI_CHAR required for converting the input
|
/** 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_pInputData Data in storage format to be converted to SI_CHAR.
|
||||||
* @param a_uInputDataLen Length of message_base format data in bytes. This
|
* @param a_uInputDataLen Length of storage format data in bytes. This
|
||||||
* must be the actual length of the data, including
|
* must be the actual length of the data, including
|
||||||
* NULL byte if NULL terminated string is required.
|
* NULL byte if NULL terminated string is required.
|
||||||
* @return Number of SI_CHAR required by the string when
|
* @return Number of SI_CHAR required by the string when
|
||||||
@ -3069,11 +3069,11 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert the input string from the message_base format to SI_CHAR.
|
/** Convert the input string from the storage format to SI_CHAR.
|
||||||
* The message_base format is always UTF-8 or MBCS.
|
* 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_pInputData Data in storage format to be converted to SI_CHAR.
|
||||||
* @param a_uInputDataLen Length of message_base format data in bytes. This
|
* @param a_uInputDataLen Length of storage format data in bytes. This
|
||||||
* must be the actual length of the data, including
|
* must be the actual length of the data, including
|
||||||
* NULL byte if NULL terminated string is required.
|
* NULL byte if NULL terminated string is required.
|
||||||
* @param a_pOutputData Pointer to the output buffer to received the
|
* @param a_pOutputData Pointer to the output buffer to received the
|
||||||
@ -3119,13 +3119,13 @@ public:
|
|||||||
return retval != (size_t)(-1);
|
return retval != (size_t)(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Calculate the number of char required by the message_base format of this
|
/** Calculate the number of char required by the storage format of this
|
||||||
* data. The message_base format is always UTF-8 or MBCS.
|
* data. The storage format is always UTF-8 or MBCS.
|
||||||
*
|
*
|
||||||
* @param a_pInputData NULL terminated string to calculate the number of
|
* @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
|
* @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.
|
* includes space for the terminating NULL character.
|
||||||
* @return -1 cast to size_t on a conversion error.
|
* @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.
|
/** Convert the input string to the storage format of this data.
|
||||||
* The message_base format is always UTF-8 or MBCS.
|
* The storage format is always UTF-8 or MBCS.
|
||||||
*
|
*
|
||||||
* @param a_pInputData NULL terminated source string to convert. All of
|
* @param a_pInputData NULL terminated source string to convert. All of
|
||||||
* the data will be converted including the
|
* the data will be converted including the
|
||||||
@ -3244,10 +3244,10 @@ public:
|
|||||||
~SI_ConvertW() { if (m_pConverter) ucnv_close(m_pConverter); }
|
~SI_ConvertW() { if (m_pConverter) ucnv_close(m_pConverter); }
|
||||||
|
|
||||||
/** Calculate the number of UChar required for converting the input
|
/** 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_pInputData Data in storage format to be converted to UChar.
|
||||||
* @param a_uInputDataLen Length of message_base format data in bytes. This
|
* @param a_uInputDataLen Length of storage format data in bytes. This
|
||||||
* must be the actual length of the data, including
|
* must be the actual length of the data, including
|
||||||
* NULL byte if NULL terminated string is required.
|
* NULL byte if NULL terminated string is required.
|
||||||
* @return Number of UChar required by the string when
|
* @return Number of UChar required by the string when
|
||||||
@ -3282,11 +3282,11 @@ public:
|
|||||||
return (size_t) nLen;
|
return (size_t) nLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert the input string from the message_base format to UChar.
|
/** Convert the input string from the storage format to UChar.
|
||||||
* The message_base format is always UTF-8 or MBCS.
|
* The storage format is always UTF-8 or MBCS.
|
||||||
*
|
*
|
||||||
* @param a_pInputData Data in message_base format to be converted to UChar.
|
* @param a_pInputData Data in storage format to be converted to UChar.
|
||||||
* @param a_uInputDataLen Length of message_base format data in bytes. This
|
* @param a_uInputDataLen Length of storage format data in bytes. This
|
||||||
* must be the actual length of the data, including
|
* must be the actual length of the data, including
|
||||||
* NULL byte if NULL terminated string is required.
|
* NULL byte if NULL terminated string is required.
|
||||||
* @param a_pOutputData Pointer to the output buffer to received the
|
* @param a_pOutputData Pointer to the output buffer to received the
|
||||||
@ -3322,13 +3322,13 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Calculate the number of char required by the message_base format of this
|
/** Calculate the number of char required by the storage format of this
|
||||||
* data. The message_base format is always UTF-8 or MBCS.
|
* data. The storage format is always UTF-8 or MBCS.
|
||||||
*
|
*
|
||||||
* @param a_pInputData NULL terminated string to calculate the number of
|
* @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
|
* @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.
|
* includes space for the terminating NULL character.
|
||||||
* @return -1 cast to size_t on a conversion error.
|
* @return -1 cast to size_t on a conversion error.
|
||||||
*/
|
*/
|
||||||
@ -3355,8 +3355,8 @@ public:
|
|||||||
return (size_t) nLen + 1;
|
return (size_t) nLen + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert the input string to the message_base format of this data.
|
/** Convert the input string to the storage format of this data.
|
||||||
* The message_base format is always UTF-8 or MBCS.
|
* The storage format is always UTF-8 or MBCS.
|
||||||
*
|
*
|
||||||
* @param a_pInputData NULL terminated source string to convert. All of
|
* @param a_pInputData NULL terminated source string to convert. All of
|
||||||
* the data will be converted including the
|
* the data will be converted including the
|
||||||
@ -3465,10 +3465,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Calculate the number of SI_CHAR required for converting the input
|
/** 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_pInputData Data in storage format to be converted to SI_CHAR.
|
||||||
* @param a_uInputDataLen Length of message_base format data in bytes. This
|
* @param a_uInputDataLen Length of storage format data in bytes. This
|
||||||
* must be the actual length of the data, including
|
* must be the actual length of the data, including
|
||||||
* NULL byte if NULL terminated string is required.
|
* NULL byte if NULL terminated string is required.
|
||||||
* @return Number of SI_CHAR required by the string when
|
* @return Number of SI_CHAR required by the string when
|
||||||
@ -3490,11 +3490,11 @@ public:
|
|||||||
return (size_t)(retval > 0 ? retval : -1);
|
return (size_t)(retval > 0 ? retval : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert the input string from the message_base format to SI_CHAR.
|
/** Convert the input string from the storage format to SI_CHAR.
|
||||||
* The message_base format is always UTF-8 or MBCS.
|
* 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_pInputData Data in storage format to be converted to SI_CHAR.
|
||||||
* @param a_uInputDataLen Length of message_base format data in bytes. This
|
* @param a_uInputDataLen Length of storage format data in bytes. This
|
||||||
* must be the actual length of the data, including
|
* must be the actual length of the data, including
|
||||||
* NULL byte if NULL terminated string is required.
|
* NULL byte if NULL terminated string is required.
|
||||||
* @param a_pOutputData Pointer to the output buffer to received the
|
* @param a_pOutputData Pointer to the output buffer to received the
|
||||||
@ -3516,13 +3516,13 @@ public:
|
|||||||
return (nSize > 0);
|
return (nSize > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Calculate the number of char required by the message_base format of this
|
/** Calculate the number of char required by the storage format of this
|
||||||
* data. The message_base format is always UTF-8.
|
* data. The storage format is always UTF-8.
|
||||||
*
|
*
|
||||||
* @param a_pInputData NULL terminated string to calculate the number of
|
* @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
|
* @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.
|
* includes space for the terminating NULL character.
|
||||||
* @return -1 cast to size_t on a conversion error.
|
* @return -1 cast to size_t on a conversion error.
|
||||||
*/
|
*/
|
||||||
@ -3536,8 +3536,8 @@ public:
|
|||||||
return (size_t) (retval > 0 ? retval : -1);
|
return (size_t) (retval > 0 ? retval : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert the input string to the message_base format of this data.
|
/** Convert the input string to the storage format of this data.
|
||||||
* The message_base format is always UTF-8 or MBCS.
|
* The storage format is always UTF-8 or MBCS.
|
||||||
*
|
*
|
||||||
* @param a_pInputData NULL terminated source string to convert. All of
|
* @param a_pInputData NULL terminated source string to convert. All of
|
||||||
* the data will be converted including the
|
* the data will be converted including the
|
||||||
|
@ -143,7 +143,7 @@ struct evbuffer_iovec {
|
|||||||
#endif
|
#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
|
@return a pointer to a newly allocated evbuffer struct, or NULL if an error
|
||||||
occurred
|
occurred
|
||||||
@ -151,7 +151,7 @@ struct evbuffer_iovec {
|
|||||||
EVENT2_EXPORT_SYMBOL
|
EVENT2_EXPORT_SYMBOL
|
||||||
struct evbuffer *evbuffer_new(void);
|
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
|
@param buf pointer to the evbuffer to be freed
|
||||||
*/
|
*/
|
||||||
|
@ -316,7 +316,7 @@ EVENT2_EXPORT_SYMBOL
|
|||||||
int bufferevent_get_priority(const struct bufferevent *bufev);
|
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
|
If there is pending data to write on the bufferevent, it probably won't be
|
||||||
flushed before the bufferevent is freed.
|
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,
|
size_t write_rate, size_t write_burst,
|
||||||
const struct timeval *tick_len);
|
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
|
Note: 'cfg' is not currently reference-counted; it is not safe to free it
|
||||||
until no bufferevent is using it.
|
until no bufferevent is using it.
|
||||||
|
@ -107,7 +107,7 @@ struct evthread_lock_callbacks {
|
|||||||
/** Function to allocate and initialize new lock of type 'locktype'.
|
/** Function to allocate and initialize new lock of type 'locktype'.
|
||||||
* Returns NULL on failure. */
|
* Returns NULL on failure. */
|
||||||
void *(*alloc)(unsigned locktype);
|
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'. */
|
* with type 'locktype'. */
|
||||||
void (*free)(void *lock, unsigned locktype);
|
void (*free)(void *lock, unsigned locktype);
|
||||||
/** Acquire an already-allocated lock at 'lock' with mode 'mode'.
|
/** Acquire an already-allocated lock at 'lock' with mode 'mode'.
|
||||||
|
@ -808,7 +808,7 @@ EVENT2_EXPORT_SYMBOL
|
|||||||
int evutil_getaddrinfo(const char *nodename, const char *servname,
|
int evutil_getaddrinfo(const char *nodename, const char *servname,
|
||||||
const struct evutil_addrinfo *hints_in, struct evutil_addrinfo **res);
|
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
|
EVENT2_EXPORT_SYMBOL
|
||||||
void evutil_freeaddrinfo(struct evutil_addrinfo *ai);
|
void evutil_freeaddrinfo(struct evutil_addrinfo *ai);
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@
|
|||||||
*/
|
*/
|
||||||
#define FIELD_IN_ADD_INDEX (1 << 20)
|
#define FIELD_IN_ADD_INDEX (1 << 20)
|
||||||
#define FIELD_IS_RENAMED (1 << 21) /**< Intern: Field is being renamed */
|
#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_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 24 /**< Field column format, bit 24-25 */
|
||||||
#define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT)
|
#define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT)
|
||||||
@ -232,7 +232,7 @@
|
|||||||
128 /**< Remove all bin logs in the index \
|
128 /**< Remove all bin logs in the index \
|
||||||
and truncate the index, RESET MASTER */
|
and truncate the index, RESET MASTER */
|
||||||
#define REFRESH_ERROR_LOG 256 /**< Rotate only the error log */
|
#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_BINARY_LOG 1024 /**< Flush the binary log */
|
||||||
#define REFRESH_RELAY_LOG 2048 /**< Flush the relay log */
|
#define REFRESH_RELAY_LOG 2048 /**< Flush the relay log */
|
||||||
#define REFRESH_GENERAL_LOG 4096 /**< Flush the general 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,
|
SHUTDOWN_WAIT_TRANSACTIONS = MYSQL_SHUTDOWN_KILLABLE_TRANS,
|
||||||
/** Wait for existing updates to finish (=> no partial MyISAM update) */
|
/** Wait for existing updates to finish (=> no partial MyISAM update) */
|
||||||
SHUTDOWN_WAIT_UPDATES = MYSQL_SHUTDOWN_KILLABLE_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),
|
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,
|
SHUTDOWN_WAIT_CRITICAL_BUFFERS = (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
|
||||||
/** Query level of the KILL command */
|
/** Query level of the KILL command */
|
||||||
KILL_QUERY = 254,
|
KILL_QUERY = 254,
|
||||||
|
@ -106,7 +106,7 @@ public:
|
|||||||
/// This commits all updates to the database using the connection
|
/// This commits all updates to the database using the connection
|
||||||
/// we were created with since this object was created. This is a
|
/// we were created with since this object was created. This is a
|
||||||
/// no-op if the table isn't stored using a transaction-aware
|
/// 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.
|
/// details.
|
||||||
void commit();
|
void commit();
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// This abandons all SQL statements made on the connection since
|
/// This abandons all SQL statements made on the connection since
|
||||||
/// this object was created. This only works on tables stored using
|
/// 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.
|
/// MySQL manual for details.
|
||||||
void rollback();
|
void rollback();
|
||||||
|
|
||||||
|
@ -1231,7 +1231,7 @@ public:
|
|||||||
RAPIDJSON_ASSERT(false); // see above note
|
RAPIDJSON_ASSERT(false); // see above note
|
||||||
|
|
||||||
#if RAPIDJSON_HAS_CXX11
|
#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
|
// Use static buffer and placement-new to prevent destruction, with
|
||||||
// alignas() to ensure proper alignment.
|
// alignas() to ensure proper alignment.
|
||||||
alignas(GenericValue) thread_local static char buffer[sizeof(GenericValue)];
|
alignas(GenericValue) thread_local static char buffer[sizeof(GenericValue)];
|
||||||
@ -2490,7 +2490,7 @@ typedef GenericValue<UTF8<> > Value;
|
|||||||
//! A document for parsing JSON text as DOM.
|
//! A document for parsing JSON text as DOM.
|
||||||
/*!
|
/*!
|
||||||
\note implements Handler concept
|
\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 Allocator Allocator for allocating memory for the DOM
|
||||||
\tparam StackAllocator Allocator for allocating memory for stack during parsing.
|
\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.
|
\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.
|
||||||
|
@ -128,7 +128,7 @@ private:
|
|||||||
// Round up to the next cache line (align the base address)
|
// Round up to the next cache line (align the base address)
|
||||||
std::uintptr_t result = (base + cache_line_alignment) & ~(cache_line_alignment - 1);
|
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((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.
|
// Record where block actually starts.
|
||||||
(reinterpret_cast<std::uintptr_t*>(result))[-1] = base;
|
(reinterpret_cast<std::uintptr_t*>(result))[-1] = base;
|
||||||
|
@ -95,7 +95,7 @@ public:
|
|||||||
|
|
||||||
template <typename F>
|
template <typename F>
|
||||||
void run_once(F&& f) {
|
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
|
// Initialize internal state
|
||||||
new(&m_storage) storage_t();
|
new(&m_storage) storage_t();
|
||||||
m_storage.m_arena.execute([&] {
|
m_storage.m_arena.execute([&] {
|
||||||
|
@ -27,7 +27,7 @@ namespace detail {
|
|||||||
namespace d1 {
|
namespace d1 {
|
||||||
/** \name combinable **/
|
/** \name combinable **/
|
||||||
//@{
|
//@{
|
||||||
//! Thread-local message_base with optional reduction
|
//! Thread-local storage with optional reduction
|
||||||
/** @ingroup containers */
|
/** @ingroup containers */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class combinable {
|
class combinable {
|
||||||
|
@ -83,7 +83,7 @@ private:
|
|||||||
value_function_type my_value_function;
|
value_function_type my_value_function;
|
||||||
aggregator_type my_aggregator;
|
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
|
history_list_type my_history_list; // history list for unused objects
|
||||||
const std::size_t my_history_list_capacity; // history list's allowed capacity
|
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<typename KeyT, typename ValT, typename KeyToValFunctorT>
|
template<typename KeyT, typename ValT, typename KeyToValFunctorT>
|
||||||
|
@ -651,7 +651,7 @@ struct construct_by_args: no_assign {
|
|||||||
construct_by_args( P&& ... args ) : pack(std::forward<P>(args)...) {}
|
construct_by_args( P&& ... args ) : pack(std::forward<P>(args)...) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// message_base for initialization function pointer
|
// storage for initialization function pointer
|
||||||
// TODO: consider removing the template parameter T here and in callback_leaf
|
// TODO: consider removing the template parameter T here and in callback_leaf
|
||||||
class callback_base {
|
class callback_base {
|
||||||
public:
|
public:
|
||||||
@ -734,7 +734,7 @@ template <typename T> using is_callable_no_args = supports<T, has_empty_braces_o
|
|||||||
- thread-local copies do not move (during lifetime, and excepting clear()) so the address of a copy is invariant.
|
- thread-local copies do not move (during lifetime, and excepting clear()) so the address of a copy is invariant.
|
||||||
- the contained objects need not have operator=() defined if combine is not used.
|
- the contained objects need not have operator=() defined if combine is not used.
|
||||||
- enumerable_thread_specific containers may be copy-constructed or assigned.
|
- enumerable_thread_specific containers may be copy-constructed or assigned.
|
||||||
- thread-local copies can be managed by hash-table, or can be accessed via TLS message_base for speed.
|
- thread-local copies can be managed by hash-table, or can be accessed via TLS storage for speed.
|
||||||
- outside of parallel contexts, the contents of all thread-local copies are accessible by iterator or using combine or combine_each methods
|
- outside of parallel contexts, the contents of all thread-local copies are accessible by iterator or using combine or combine_each methods
|
||||||
|
|
||||||
@par Segmented iterator
|
@par Segmented iterator
|
||||||
@ -932,7 +932,7 @@ private:
|
|||||||
using std::swap;
|
using std::swap;
|
||||||
__TBB_ASSERT( this!=&other, nullptr);
|
__TBB_ASSERT( this!=&other, nullptr);
|
||||||
swap(my_construct_callback, other.my_construct_callback);
|
swap(my_construct_callback, other.my_construct_callback);
|
||||||
// concurrent_vector::swap() preserves message_base space,
|
// concurrent_vector::swap() preserves storage space,
|
||||||
// so addresses to the vector kept in ETS hash table remain valid.
|
// so addresses to the vector kept in ETS hash table remain valid.
|
||||||
swap(my_locals, other.my_locals);
|
swap(my_locals, other.my_locals);
|
||||||
this->ets_base<ETS_key_type>::table_swap(other);
|
this->ets_base<ETS_key_type>::table_swap(other);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user