void * zsock_resolve (void *self) { assert (self); if (zsock_is (self)) return ((zsock_t *) self)->handle; else if (zactor_is (self)) return zactor_resolve (self); else return self; }
/* ================ run_client() ================ */ int run_client(const char *endpoint, int op_code, int total_threads, uint32_t total_files, const char *key, const char *filename, int verbose) { info_log("run_client() with op_code:%d endpoint:%s threads:%d count:%d key:%s filename:%s", op_code, endpoint, total_threads, total_files, key, filename); if ( prepare_file_data(filename) != 0 ){ return -1; } total_actors = total_threads; client_t **clients = (client_t**)malloc(sizeof(client_t*) * total_actors); for ( int i = 0 ; i < total_actors ; i++ ){ client_t *client = client_new(i, endpoint); client->op_code = op_code; client->total_threads = total_threads; client->total_files = total_files; client->key = key; client->filename = filename; client->file_data = file_data; client->file_size = file_size; client_create_actor(client); clients[i] = client; } zloop_t *loop = zloop_new(); zloop_set_verbose(loop, verbose); for ( int i = 0 ; i < total_actors ; i++ ){ zactor_t *actor = clients[i]->actor; zloop_reader(loop, (zsock_t*)zactor_resolve(actor), handle_pullin_on_client_pipe, clients[i]); } zloop_start(loop); zloop_destroy(&loop); for ( int i = 0 ; i < total_actors ; i++ ){ client_free(clients[i]); } return 0; }
/// // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. void * QZactor::resolve (void *self) { void * rv = zactor_resolve (self); return rv; }