#include #include #include #include #include #include #include #include #include #include "fastcommon/logger.h" #include "fastcommon/shared_func.h" #include "fastcommon/sched_thread.h" #include "fastcommon/ini_file_reader.h" #include "fastcommon/fast_mblock.h" #include "fastcommon/sockopt.h" #include "fastcommon/system_info.h" #include "fastcommon/local_ip_func.h" struct my_struct { struct fast_mblock_man *mblock; void *obj; }; static int test_delay(void *args) { struct my_struct *my; my = (struct my_struct *)args; fast_mblock_free_object(my->mblock, my->obj); return 0; } int main(int argc, char *argv[]) { int64_t start_time; int64_t end_time; int64_t mem_size; struct fast_mblock_man mblock1; struct fast_mblock_man mblock2; struct my_struct *objs; void *obj1; void *obj2; int reclaim_target; int reclaim_count; int i; int count; pthread_t schedule_tid; ScheduleArray scheduleArray; ScheduleEntry scheduleEntries[1]; volatile bool continue_flag = true; FastIFConfig if_configs[32]; struct fast_statfs stats[32]; start_time = get_current_time_ms(); srand(time(NULL)); log_init(); g_log_context.log_level = LOG_DEBUG; load_local_host_ip_addrs(); print_local_host_ip_addrs(); printf("first_local_ip: %s\n", get_first_local_ip()); getifconfigs(if_configs, sizeof(if_configs) / sizeof(if_configs[0]), &count); printf("ifconfig count: %d\n", count); for (i=0; i %s %s %ld %ld %ld %ld %ld %ld %ld\n", stats[i].f_mntfromname, stats[i].f_mntonname, stats[i].f_fstypename, stats[i].f_type, stats[i].f_bsize, stats[i].f_blocks, stats[i].f_bfree, stats[i].f_bavail, stats[i].f_files, stats[i].f_ffree); } #if defined(OS_LINUX) || defined(OS_FREEBSD) { FastProcessInfo *processes; struct fast_sysinfo info; struct stat st; get_processes(&processes, &count); printf("process count: %d\n", count); for (i=0; i 1) { filename = argv[1]; } else { filename = "/etc/mc/worker.conf"; } if ((result=iniLoadFromFile(filename, &iniContext)) != 0) { logError("file: "__FILE__", line: %d, " "load conf file \"%s\" fail, ret code: %d", __LINE__, filename, result); return result; } //iniPrintItems(&iniContext); iniFreeContext(&iniContext); } */ sched_enable_delay_task(); scheduleArray.entries = scheduleEntries; scheduleArray.count = 0; sched_start(&scheduleArray, &schedule_tid, 64 * 1024, (bool * volatile)&continue_flag); if (get_sys_total_mem_size(&mem_size) == 0) { printf("total memory size: %"PRId64" MB\n", mem_size / (1024 * 1024)); } printf("cpu count: %d\n", get_sys_cpu_count()); end_time = get_current_time_ms(); logInfo("time used: %d ms", (int)(end_time - start_time)); fast_mblock_manager_init(); fast_mblock_init_ex1(&mblock1, "mblock1", 1024, 128, 0, NULL, NULL, false); fast_mblock_init_ex1(&mblock2, "mblock2", 1024, 100, 0, NULL, NULL, false); count = 2048; objs = (struct my_struct *)malloc(sizeof(struct my_struct) * count); for (i=0; i