示例#1
0
int main (int argc, const char * argv[]) {
	struct settings *settings = local_config();
	settings->hash_power = 0;
	settings->prealloc = true;
	settings->evict_opt = EVICT_LRU;
	settings->maxbytes = 200 * 1024 * 1024;
	settings->slab_size = 1024 * 1024;
	settings->use_freeq = true;
	settings->use_lruq = true;
	settings->profile_last_id = 12;
	int i = 0, j = 0, n = 0;
	for (i = 1; i < 13; i++) {
		settings->profile[i] = 100 * i;
	}
	bool result = local_start();
	if (result) printf("cache started\n");
	else {
		printf("cache started fail\n");
		return 1;
	}
	char *key = (char*)malloc(8);
	char *value = (char*)malloc(900);
	for (i = 0; i < 10000; i++) {
		for (j = 0; j < 10000; j++) {
			int *ptr = (int*)key;
			*ptr = i;
			*(ptr++) = j;
			n = i + j;
			n = (n % 9) * 100 + 50;
			ptr = (int*)value;
			*ptr = i;
			*(ptr + n - 4) = j;
			result = local_put(key, 8, 10, value, n);
			if (!result) {
				printf("cache put item fail\n");
				printf("%d %d\n", i, j);
				return 1;
			}
			struct item *res = local_get(key, 8);
			if (res == NULL || res->nbyte != n) {
				printf("cache get item fail\n");
				printf("%d %d\n", i, j);
				return 1;
			}
			char *data = item_data(res);
			if (*((int*)data) != i) {
				printf("cache get value fail\n");
				printf("%d %d\n", i, j);
				return 1;
			}
		}
	}
	return 0;
}
示例#2
0
      static void 
      run_impl(const DistributedGraph& g,
               typename graph_traits<DistributedGraph>::vertex_descriptor s,
               PredecessorMap predecessor, DistanceMap distance, 
               Lookahead lookahead, WeightMap weight, IndexMap index_map, 
               ColorMap color_map, Compare compare, Combine combine, 
               DistInf inf, DistZero zero, DijkstraVisitor vis)
      {
        BGL_FORALL_VERTICES_T(u, g, DistributedGraph)
          BGL_FORALL_OUTEDGES_T(u, e, g, DistributedGraph)
            local_put(color_map, target(e, g), white_color);

        graph::detail::parallel_dijkstra_impl2<Lookahead>
          ::run(g, s, predecessor, distance, lookahead, weight, index_map,
                color_map, compare, combine, inf, zero, vis);
      }
示例#3
0
inline void
put(const caching_property_map<PropertyMap>& pm, const Key& key,
    const Value& value)
{ local_put(pm.base(), key, value); }