高并发撮合系统
标签:
•
文件类型: .rar
•
文件大小: 1.73MB
•
下载次数: 1
•
币圈的撮合系统,高并发,使用了字典哈希表,以及跳跃表进行撮合。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3622 2018-05-23 15:00 matchengineconfig.json
文件 365 2018-05-23 15:00 matchenginemakefile
文件 5937072 2018-05-23 15:00 matchenginematchengine.exe
文件 9353 2018-05-23 15:00 matchengineme_balance.c
文件 1284 2018-05-23 15:00 matchengineme_balance.h
文件 29752 2018-05-23 15:00 matchengineme_balance.o
文件 5960 2018-05-23 15:00 matchengineme_cli.c
文件 146 2018-05-23 15:00 matchengineme_cli.h
文件 30080 2018-05-23 15:00 matchengineme_cli.o
文件 5410 2018-05-23 15:00 matchengineme_config.c
文件 2098 2018-05-23 15:00 matchengineme_config.h
文件 20480 2018-05-23 15:00 matchengineme_config.o
文件 6745 2018-05-23 15:00 matchengineme_dump.c
文件 317 2018-06-15 09:51 matchengineme_dump.h
文件 46328 2018-05-23 15:00 matchengineme_dump.o
文件 11026 2018-05-23 15:00 matchengineme_history.c
文件 637 2018-05-23 15:00 matchengineme_history.h
文件 53360 2018-05-23 15:00 matchengineme_history.o
文件 14171 2018-05-23 15:00 matchengineme_load.c
文件 393 2018-05-23 15:00 matchengineme_load.h
文件 52248 2018-05-23 15:00 matchengineme_load.o
文件 3634 2018-05-23 15:00 matchengineme_main.c
文件 23640 2018-05-23 15:00 matchengineme_main.o
文件 36156 2018-05-23 15:00 matchengineme_market.c
文件 1952 2018-05-23 15:00 matchengineme_market.h
文件 68440 2018-05-23 15:00 matchengineme_market.o
文件 7953 2018-05-23 15:00 matchengineme_message.c
文件 786 2018-05-23 15:00 matchengineme_message.h
文件 47408 2018-05-23 15:00 matchengineme_message.o
文件 4447 2018-05-23 15:00 matchengineme_operlog.c
............此处省略19个文件信息
/*
* Description:
* History: yang@haipo.me 2017/03/15 create
*/
# include “me_config.h“
# include “me_balance.h“
dict_t *dict_balance;
static dict_t *dict_asset;
struct asset_type {
int prec_save;
int prec_show;
};
static uint32_t asset_dict_hash_function(const void *key)
{
return dict_generic_hash_function(key strlen(key));
}
static void *asset_dict_key_dup(const void *key)
{
return strdup(key);
}
static void *asset_dict_val_dup(const void *val)
{
struct asset_type *obj = malloc(sizeof(struct asset_type));
if (obj == NULL)
return NULL;
memcpy(obj val sizeof(struct asset_type));
return obj;
}
static int asset_dict_key_compare(const void *key1 const void *key2)
{
return strcmp(key1 key2);
}
static void asset_dict_key_free(void *key)
{
free(key);
}
static void asset_dict_val_free(void *val)
{
free(val);
}
static uint32_t balance_dict_hash_function(const void *key)
{
return dict_generic_hash_function(key sizeof(struct balance_key));
}
static void *balance_dict_key_dup(const void *key)
{
struct balance_key *obj = malloc(sizeof(struct balance_key));
if (obj == NULL)
return NULL;
memcpy(obj key sizeof(struct balance_key));
return obj;
}
static void *balance_dict_val_dup(const void *val)
{
return mpd_qncopy(val);
}
static int balance_dict_key_compare(const void *key1 const void *key2)
{
return memcmp(key1 key2 sizeof(struct balance_key));
}
static void balance_dict_key_free(void *key)
{
free(key);
}
static void balance_dict_val_free(void *val)
{
mpd_del(val);
}
static int init_dict(void)
{
dict_types type;
memset(&type 0 sizeof(type));
type.hash_function = asset_dict_hash_function;
type.key_compare = asset_dict_key_compare;
type.key_dup = asset_dict_key_dup;
type.key_destructor = asset_dict_key_free;
type.val_dup = asset_dict_val_dup;
type.val_destructor = asset_dict_val_free;
dict_asset = dict_create(&type 64);
if (dict_asset == NULL)
return -__LINE__;
memset(&type 0 sizeof(type));
type.hash_function = balance_dict_hash_function;
type.key_compare = balance_dict_key_compare;
type.key_dup = balance_dict_key_dup;
type.key_destructor = balance_dict_key_free;
type.val_dup = balance_dict_val_dup;
type.val_destructor = balance_dict_val_free;
dict_balance = dict_create(&type 64);
if (dict_balance == NULL)
return -__LINE__;
return 0;
}
int init_balance()
{
ERR_RET(init_dict());
for (size_t i = 0; i < settings.asset_num; ++i) {
struct asset_type type;
type.prec_save = settings.assets[i].prec_save;
type.prec_show = settings.assets[i].prec_show;
if (dict_add(dict_asset settings.assets[i].name &type) == NULL)
return -__LINE__;
}
return 0;
}
static struct asset_type *get_asset_type(const char *asset)
{
dict_entry *entry = dict_
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3622 2018-05-23 15:00 matchengineconfig.json
文件 365 2018-05-23 15:00 matchenginemakefile
文件 5937072 2018-05-23 15:00 matchenginematchengine.exe
文件 9353 2018-05-23 15:00 matchengineme_balance.c
文件 1284 2018-05-23 15:00 matchengineme_balance.h
文件 29752 2018-05-23 15:00 matchengineme_balance.o
文件 5960 2018-05-23 15:00 matchengineme_cli.c
文件 146 2018-05-23 15:00 matchengineme_cli.h
文件 30080 2018-05-23 15:00 matchengineme_cli.o
文件 5410 2018-05-23 15:00 matchengineme_config.c
文件 2098 2018-05-23 15:00 matchengineme_config.h
文件 20480 2018-05-23 15:00 matchengineme_config.o
文件 6745 2018-05-23 15:00 matchengineme_dump.c
文件 317 2018-06-15 09:51 matchengineme_dump.h
文件 46328 2018-05-23 15:00 matchengineme_dump.o
文件 11026 2018-05-23 15:00 matchengineme_history.c
文件 637 2018-05-23 15:00 matchengineme_history.h
文件 53360 2018-05-23 15:00 matchengineme_history.o
文件 14171 2018-05-23 15:00 matchengineme_load.c
文件 393 2018-05-23 15:00 matchengineme_load.h
文件 52248 2018-05-23 15:00 matchengineme_load.o
文件 3634 2018-05-23 15:00 matchengineme_main.c
文件 23640 2018-05-23 15:00 matchengineme_main.o
文件 36156 2018-05-23 15:00 matchengineme_market.c
文件 1952 2018-05-23 15:00 matchengineme_market.h
文件 68440 2018-05-23 15:00 matchengineme_market.o
文件 7953 2018-05-23 15:00 matchengineme_message.c
文件 786 2018-05-23 15:00 matchengineme_message.h
文件 47408 2018-05-23 15:00 matchengineme_message.o
文件 4447 2018-05-23 15:00 matchengineme_operlog.c
............此处省略19个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)