本文整理汇总了C++中cache_create函数的典型用法代码示例。如果您正苦于以下问题:C++ cache_create函数的具体用法?C++ cache_create怎么用?C++ cache_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cache_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sim_check_options
/* check simulator-specific option values */
void
sim_check_options(void) /* command line arguments */
{
/* use a level 1 D-cache? */
if (mystricmp(cache_dl1_opt.opt, "none"))
{
cache_check_options(&cache_dl1_opt);
cache_dl1 = cache_create(&cache_dl1_opt);
}
/* use a level 1 I-cache? */
if (mystricmp(cache_il1_opt.opt, "none"))
{
if (!mystricmp(cache_il1_opt.opt, "dl1"))
{
if (!cache_dl1)
fatal("L1 I-cache cannot access L1 D-cache as it's undefined");
cache_il1 = cache_dl1;
}
else /* il1 is defined */
{
cache_check_options(&cache_il1_opt);
cache_il1 = cache_create(&cache_il1_opt);
}
}
if (mystricmp(cache_l2_opt.opt, "none"))
{
if (!cache_dl1 && !cache_il1)
fatal("can't have an L2 D-cache without an L1 D-cache or I-cache!");
cache_check_options(&cache_l2_opt);
cache_l2 = cache_create(&cache_l2_opt);
}
/* use a D-TLB? */
if (mystricmp(dtlb_opt.opt, "none"))
{
cache_check_options(&dtlb_opt);
dtlb = cache_create(&dtlb_opt);
}
/* use an I-TLB? */
if (mystricmp(itlb_opt.opt, "none"))
{
if (!mystricmp(itlb_opt.opt, "dtlb"))
{
if (!dtlb)
fatal("I-TLB cannot use D-TLB as it is undefined");
itlb = dtlb;
}
else
{
cache_check_options(&itlb_opt);
itlb = cache_create(&itlb_opt);
}
}
}
开发者ID:HackLinux,项目名称:sim-R10K,代码行数:59,代码来源:sim-cache.c
示例2: setup_thread
/*
* Set up a thread's information.
*/
static void setup_thread(LIBEVENT_THREAD *me) {
#if defined(LIBEVENT_VERSION_NUMBER) && LIBEVENT_VERSION_NUMBER >= 0x02000101
struct event_config *ev_config;
ev_config = event_config_new();
event_config_set_flag(ev_config, EVENT_BASE_FLAG_NOLOCK);
me->base = event_base_new_with_config(ev_config);
event_config_free(ev_config);
#else
me->base = event_init();
#endif
if (! me->base) {
fprintf(stderr, "Can't allocate event base\n");
exit(1);
}
/* Listen for notifications from other threads */
event_set(&me->notify_event, me->notify_receive_fd,
EV_READ | EV_PERSIST, thread_libevent_process, me);
event_base_set(me->base, &me->notify_event);
if (event_add(&me->notify_event, 0) == -1) {
fprintf(stderr, "Can't monitor libevent notify pipe\n");
exit(1);
}
me->new_conn_queue = malloc(sizeof(struct conn_queue));
if (me->new_conn_queue == NULL) {
perror("Failed to allocate memory for connection queue");
exit(EXIT_FAILURE);
}
cq_init(me->new_conn_queue);
if (pthread_mutex_init(&me->stats.mutex, NULL) != 0) {
perror("Failed to initialize mutex");
exit(EXIT_FAILURE);
}
me->suffix_cache = cache_create("suffix", SUFFIX_SIZE, sizeof(char*),
NULL, NULL);
if (me->suffix_cache == NULL) {
fprintf(stderr, "Failed to create suffix cache\n");
exit(EXIT_FAILURE);
}
#ifdef EXTSTORE
me->io_cache = cache_create("io", sizeof(io_wrap), sizeof(char*), NULL, NULL);
if (me->io_cache == NULL) {
fprintf(stderr, "Failed to create IO object cache\n");
exit(EXIT_FAILURE);
}
#endif
}
开发者ID:sidgwick,项目名称:memcached,代码行数:55,代码来源:thread.c
示例3: init_block_list
void
init_block_list(int firewall)
{
// Initialize cache
#ifdef __linux__
if (firewall)
init_firewall();
else
mode = NO_FIREWALL_MODE;
cache_create(&block_list, 256, free_firewall_rule);
#else
cache_create(&block_list, 256, NULL);
#endif
}
开发者ID:ss-plus,项目名称:shadowsocksR-libev,代码行数:14,代码来源:acl.c
示例4: callback_open
static int callback_open(const char *path, struct fuse_file_info *finfo) {
Node *node;
mylog("::open(%s)\n", path);
/* We allow opens, unless they're tring to write, sneaky
* people. */
int flags = finfo->flags;
if ((flags & O_WRONLY) || (flags & O_RDWR) || (flags & O_CREAT) || (flags & O_EXCL) || (flags & O_TRUNC) || (flags & O_APPEND)) {
return(-EROFS);
}
node = get_node_path(path);
if (node == NULL) {
return(-ENOENT);
}
/* create the associated cache */
if ((node->file)&&(!node->special)) { /* only handle cache for files */
/* do not create cache for empty files */
if (node->size > 0) {
if (cache_create(path, node->size) == NULL) {
/* something goes wrong. Refuse open */
return(-EBUSY);
}
}
}
stat_open++;
stat_used++;
/* ok */
return(0);
}
开发者ID:Hexasoft,项目名称:WebFS,代码行数:34,代码来源:webfs.c
示例5: skeleton_init_driver
static EventEntry* skeleton_init_driver(void)
{
struct skeleton_entry *e = calloc(1, sizeof(struct skeleton_entry));
if (e == NULL) return NULL;
NEOERR *err;
e->base.name = (unsigned char*)strdup(PLUGIN_NAME);
e->base.ksize = strlen(PLUGIN_NAME);
e->base.process_driver = skeleton_process_driver;
e->base.stop_driver = skeleton_stop_driver;
//mevent_add_timer(&e->base.timers, 60, true, hint_timer_up_term);
//char *s = hdf_get_value(g_cfg, CONFIG_PATH".dbsn", NULL);
//err = mdb_init(&e->db, s);
//JUMP_NOK(err, error);
e->cd = cache_create(hdf_get_int_value(g_cfg, CONFIG_PATH".numobjs", 1024), 0);
if (e->cd == NULL) {
wlog("init cache failure");
goto error;
}
return (EventEntry*)e;
error:
if (e->base.name) free(e->base.name);
if (e->db) mdb_destroy(e->db);
if (e->cd) cache_free(e->cd);
free(e);
return NULL;
}
开发者ID:adderly,项目名称:cmoon,代码行数:31,代码来源:mevent_skeleton.c
示例6: calloc
/*
** **********************************************************************
** * PUBLIC INTERFACE
** * See protocol_handler.h for function description
** **********************************************************************
*/
struct memcached_protocol_st *memcached_protocol_create_instance(void)
{
struct memcached_protocol_st *ret= calloc(1, sizeof(*ret));
if (ret != NULL)
{
ret->recv= default_recv;
ret->send= default_send;
ret->drain= drain_output;
ret->spool= spool_output;
ret->input_buffer_size= 1 * 1024 * 1024;
ret->input_buffer= malloc(ret->input_buffer_size);
if (ret->input_buffer == NULL)
{
free(ret);
ret= NULL;
return NULL;
}
ret->buffer_cache= cache_create("protocol_handler",
CHUNK_BUFFERSIZE + sizeof(struct chunk_st),
0, NULL, NULL);
if (ret->buffer_cache == NULL)
{
free(ret->input_buffer);
free(ret);
}
}
return ret;
}
开发者ID:ClearwaterCore,项目名称:libmemcached-upstream,代码行数:37,代码来源:handler.c
示例7: aic_init_driver
static struct event_entry* aic_init_driver(void)
{
struct aic_entry *e = calloc(1, sizeof(struct aic_entry));
if (e == NULL) return NULL;
NEOERR *err;
e->base.name = (unsigned char*)strdup(PLUGIN_NAME);
e->base.ksize = strlen(PLUGIN_NAME);
e->base.process_driver = aic_process_driver;
e->base.stop_driver = aic_stop_driver;
char *dbsn = hdf_get_value(g_cfg, CONFIG_PATH".dbsn", NULL);
err = mdb_init(&e->db, dbsn);
JUMP_NOK(err, error);
e->cd = cache_create(hdf_get_int_value(g_cfg, CONFIG_PATH".numobjs", 1024), 0);
if (e->cd == NULL) {
wlog("init cache failure");
goto error;
}
return (struct event_entry*)e;
error:
if (e->base.name) free(e->base.name);
if (e->db) mdb_destroy(e->db);
if (e->cd) cache_free(e->cd);
free(e);
return NULL;
}
开发者ID:kingiol,项目名称:cmoon,代码行数:30,代码来源:mevent_aic.c
示例8: sylvan_init_package
/**
* Package init and quit functions
*/
void
sylvan_init_package(size_t tablesize, size_t maxsize, size_t cachesize, size_t max_cachesize)
{
if (tablesize > maxsize) tablesize = maxsize;
if (cachesize > max_cachesize) cachesize = max_cachesize;
if (maxsize > 0x000003ffffffffff) {
fprintf(stderr, "sylvan_init_package error: tablesize must be <= 42 bits!\n");
exit(1);
}
nodes = llmsset_create(tablesize, maxsize);
cache_create(cachesize, max_cachesize);
gc = 0;
barrier_init(&gcbar, lace_workers());
#if SYLVAN_AGGRESSIVE_RESIZE
gc_hook = TASK(sylvan_gc_aggressive_resize);
#else
gc_hook = TASK(sylvan_gc_default_hook);
#endif
sylvan_gc_add_mark(10, TASK(sylvan_gc_mark_cache));
sylvan_gc_add_mark(19, TASK(sylvan_gc_destroy_unmarked));
sylvan_gc_add_mark(20, TASK(sylvan_gc_call_hook));
sylvan_gc_add_mark(30, TASK(sylvan_gc_rehash));
LACE_ME;
sylvan_stats_init();
}
开发者ID:utwente-fmt,项目名称:sigrefmc,代码行数:32,代码来源:sylvan_common.c
示例9: cache_sim_init
/* cache_sim_init */
cache_handle_t* cache_sim_init(const unsigned int total_size,
const unsigned int line_size, const unsigned int associativity,
const char *policy) {
/* safety checks */
if ((0 >= total_size) || (0 >= line_size) || (0 >= associativity)) {
return NULL;
}
/* variables declaration and initialization */
cache_handle_t *cache = NULL;
printf("--------------------------------\n");
/* create the cache */
if (NULL == (cache = cache_create(total_size, line_size, associativity))) {
return NULL;
}
/* set the cache replacement policy (or algorithm) */
if (CACHE_SIM_SUCCESS != (set_policy(cache, policy))) {
cache_destroy(cache);
return NULL;
}
printf(" Cache initialized successfully \n");
printf("--------------------------------\n");
return cache;
}
开发者ID:labrick,项目名称:perfexpert,代码行数:30,代码来源:cache_sim.c
示例10: main
int main(int argc, char **argv)
{
FILE *swp;
struct cache *c;
struct matrix *m;
FILE *matrix_shared;
readargs(argc, argv);
if ((swp = fopen(swapfile, "w+")) == NULL)
error("cannot open swap file");
c = cache_create(&access_info, swp, CACHE_SIZE);
/* Read traces. */
for (int i = 0; i < ntraces; i++)
{
FILE *trace;
if ((trace = fopen(tracefiles[i], "r")) == NULL)
error("cannot open trace file");
trace_read(c, trace, i);
fclose(trace);
fprintf(stderr, "\nFechado arquivo de trace da thread %d\n\n", i);
}
/* Flushe traces on swap file. */
cache_flush(c);
/* Create communication matrix. */
fseek(swp, 0, SEEK_SET);
m = matrix_create(QTD_THREADS, QTD_THREADS);
fprintf(stderr, "\nMatriz criada\n");
matrix_generate(swp, m);
if ((matrix_shared = fopen(outfile, "w")) == NULL)
error("cannot open output file");
fprintf(stderr, "\nGravar matriz no arquivo\n");
for (int i = 0; i < ntraces; i++)
{
for(int j = 0; j < ntraces; j++)
fprintf(matrix_shared, "%d;%d;%d\n", i, j, (int) matrix_get(m, i, j));
}
/* House keeping. */
fclose(matrix_shared);
fclose(swp);
fprintf(stderr, "\n\n FIM!\n");
return (EXIT_SUCCESS);
}
开发者ID:cart-pucminas,项目名称:mapper,代码行数:60,代码来源:main.c
示例11: cache_create_test
static enum test_return cache_create_test(void)
{
cache_t *cache = cache_create("test", sizeof(uint32_t), sizeof(char*),
NULL, NULL);
assert(cache != NULL);
cache_destroy(cache);
return TEST_PASS;
}
开发者ID:bcui6611,项目名称:moxi,代码行数:8,代码来源:testapp.c
示例12: numeric_cache_create
// Numeric caches use number+1 as the id.
error_t numeric_cache_create(cache_t* c, int cache_size,
int data_size, void* context,
cache_fault_t fault, cache_evict_t evict
)
{
return cache_create(c, cache_size, numeric_hash, numeric_cmp,
data_size, context, fault, evict, numeric_copy_id, numeric_free_id);
}
开发者ID:AndreasSong,项目名称:femto,代码行数:9,代码来源:cache.c
示例13: init_block_list
void
init_block_list()
{
// Initialize cache
#ifdef __linux__
init_firewall();
#endif
cache_create(&block_list, 256, NULL);
}
开发者ID:ice6601,项目名称:shadowsocks-libev,代码行数:9,代码来源:acl.c
示例14: font_load_cached
/* Load cached font */
static struct font* font_load_cached(struct font* pf)
{
uint32_t noffset, nwidth;
unsigned char* oldfileptr = pf->buffer_position;
if (!HAVEBYTES(2 * sizeof(int32_t)))
return NULL;
/* # longs of offset*/
noffset = readlong(pf);
/* # bytes of width*/
nwidth = readlong(pf);
/* We are now at the bitmap data, this is fixed at 36.. */
pf->bits = NULL;
/* Calculate offset to offset data */
pf->buffer_position += pf->bits_size * sizeof(unsigned char);
if (pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS)
{
pf->long_offset = 0;
/* pad to 16-bit boundary */
pf->buffer_position = (unsigned char *)(((intptr_t)pf->buffer_position + 1) & ~1);
}
else
{
pf->long_offset = 1;
/* pad to 32-bit boundary*/
pf->buffer_position = (unsigned char *)(((intptr_t)pf->buffer_position + 3) & ~3);
}
if (noffset)
pf->file_offset_offset = (uint32_t)(pf->buffer_position - pf->buffer_start);
else
pf->file_offset_offset = 0;
/* Calculate offset to widths data */
if (pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS)
pf->buffer_position += noffset * sizeof(uint16_t);
else
pf->buffer_position += noffset * sizeof(uint32_t);
if (nwidth)
pf->file_width_offset = (uint32_t)(pf->buffer_position - pf->buffer_start);
else
pf->file_width_offset = 0;
pf->buffer_position = oldfileptr;
/* Create the cache */
cache_create(pf, pf->maxwidth, pf->height);
return pf;
}
开发者ID:CrashSerious,项目名称:rockbox_psgroove,代码行数:57,代码来源:font.c
示例15: crowd_cache_create
bool crowd_cache_create(apr_pool_t *pool, apr_time_t max_age, unsigned int max_entries) {
auth_cache = cache_create("auth", pool, max_age, max_entries, copy_string, free);
if (auth_cache == NULL) {
return false;
}
groups_cache = cache_create("groups", pool, max_age, max_entries, copy_groups, free_groups);
if (groups_cache == NULL) {
return false;
}
cookie_config_cache = cache_create("cookie config", pool, max_age, max_entries, copy_cookie_config, free_cookie_config);
if (cookie_config_cache == NULL) {
return false;
}
session_cache = cache_create("session", pool, max_age, max_entries, copy_string, free);
if (session_cache == NULL) {
return false;
}
return true;
}
开发者ID:CoreMedia,项目名称:cwdapache,代码行数:19,代码来源:crowd_client.c
示例16: init_udprelay
int
init_udprelay(const char *server_host, const char *server_port,
#ifdef MODULE_LOCAL
const struct sockaddr *remote_addr, const int remote_addr_len,
#ifdef MODULE_TUNNEL
const ss_addr_t tunnel_addr,
#endif
#endif
int mtu, crypto_t *crypto, int timeout, const char *iface)
{
// Initialize ev loop
struct ev_loop *loop = EV_DEFAULT;
// Initialize MTU
if (mtu > 0) {
packet_size = mtu - 1 - 28 - 2 - 64;
buf_size = packet_size * 2;
}
// Initialize cache
struct cache *conn_cache;
cache_create(&conn_cache, MAX_UDP_CONN_NUM, free_cb);
// ////////////////////////////////////////////////
// Setup server context
// Bind to port
int serverfd = create_server_socket(server_host, server_port);
if (serverfd < 0) {
FATAL("[udp] bind() error");
}
setnonblocking(serverfd);
server_ctx_t *server_ctx = new_server_ctx(serverfd);
#ifdef MODULE_REMOTE
server_ctx->loop = loop;
#endif
server_ctx->timeout = max(timeout, MIN_UDP_TIMEOUT);
server_ctx->crypto = crypto;
server_ctx->iface = iface;
server_ctx->conn_cache = conn_cache;
#ifdef MODULE_LOCAL
server_ctx->remote_addr = remote_addr;
server_ctx->remote_addr_len = remote_addr_len;
#ifdef MODULE_TUNNEL
server_ctx->tunnel_addr = tunnel_addr;
#endif
#endif
ev_io_start(loop, &server_ctx->io);
server_ctx_list[server_num++] = server_ctx;
return serverfd;
}
开发者ID:wobrea,项目名称:shadowsocks-libev,代码行数:55,代码来源:udprelay.c
示例17: external_cache_init
static int external_cache_init(void)
{
external = cache_create("external",
STATE_SYNC(sync)->external_cache_flags,
NULL);
if (external == NULL) {
dlog(LOG_ERR, "can't allocate memory for the external cache");
return -1;
}
return 0;
}
开发者ID:samm-git,项目名称:e3372h-vendor-src,代码行数:11,代码来源:external_cache.c
示例18: sizeof
/*
* Creates a child of a GapIO. The child can basically be considered as a
* read-through but write-sticky cache. By that I mean that using the child
* GapIO works as if the parent was used instead, but writes to the
* child GapIO are not propagated through to the parent until an
* explicit request is made.
*
* The purpose for this mechanism is to allow tools like the contig editor
* be able to read and write to a local cached copy of the database with
* the ability to cancel and effectively rollback all local changes made.
*/
GapIO *gio_child(GapIO *io_p) {
GapIO *io = (GapIO *)calloc(1, sizeof(*io));
io->iface = get_iface_g();
cache_create(io);
io->base = io_p;
io->dbh = io->base->dbh;
io->read_only = io->base->read_only;
io->min_bin_size = io->base->min_bin_size;
return io;
}
开发者ID:svn2github,项目名称:staden,代码行数:23,代码来源:tg_gio.c
示例19: setup_thread
/*
* Set up a thread's information.
*/
static void setup_thread(LIBEVENT_THREAD *me) {
if (! me->base) {
me->base = event_init();
if (! me->base) {
moxi_log_write("Can't allocate event base\n");
exit(1);
}
}
/* Listen for notifications from other threads */
event_set(&me->notify_event, me->notify_receive_fd,
EV_READ | EV_PERSIST, thread_libevent_process, me);
event_base_set(me->base, &me->notify_event);
if (event_add(&me->notify_event, 0) == -1) {
moxi_log_write("Can't monitor libevent notify pipe\n");
exit(1);
}
me->new_conn_queue = malloc(sizeof(struct conn_queue));
if (me->new_conn_queue == NULL) {
perror("Failed to allocate memory for connection queue");
exit(EXIT_FAILURE);
}
cq_init(me->new_conn_queue);
// TODO: Merge new_conn_queue with work_queue.
//
me->work_queue = calloc(1, sizeof(work_queue));
if (me->work_queue == NULL) {
perror("Failed to allocate memory for work queue");
exit(EXIT_FAILURE);
}
work_queue_init(me->work_queue, me->base);
if (pthread_mutex_init(&me->stats.mutex, NULL) != 0) {
perror("Failed to initialize mutex");
exit(EXIT_FAILURE);
}
me->suffix_cache = cache_create("suffix", SUFFIX_SIZE, sizeof(char*),
NULL, NULL);
if (me->suffix_cache == NULL) {
moxi_log_write("Failed to create suffix cache\n");
exit(EXIT_FAILURE);
}
me->conn_hash = genhash_init(512, strhash_ops);
if (me->conn_hash == NULL) {
moxi_log_write("Failed to create connection hash\n");
exit(EXIT_FAILURE);
}
}
开发者ID:zbase,项目名称:moxi,代码行数:56,代码来源:thread.c
示例20: cache_destructor_test
static enum test_return cache_destructor_test(void)
{
cache_t *cache = cache_create("test", sizeof(uint32_t), sizeof(char*),
NULL, cache_destructor);
char *ptr;
assert(cache != NULL);
ptr = cache_alloc(cache);
cache_free(cache, ptr);
cache_destroy(cache);
return (ptr == destruct_data) ? TEST_PASS : TEST_FAIL;
}
开发者ID:bcui6611,项目名称:moxi,代码行数:13,代码来源:testapp.c
注:本文中的cache_create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论