From 3652defe33c4832cab21c29c53e7ab0f779e005e Mon Sep 17 00:00:00 2001
From: Roman Tsisyk <roman@tsisyk.com>
Date: Fri, 17 Apr 2015 18:13:35 +0300
Subject: [PATCH] Rename async_task to coio_task

---
 src/coeio.cc              | 50 +++++++++++++++++++--------------------
 src/coeio.h               | 30 +++++++++++------------
 src/coio.cc               |  2 +-
 src/lua/bsdsocket.cc      |  2 +-
 src/lua/init.cc           |  2 +-
 src/module/mysql/mysql.cc |  6 ++---
 src/module/pg/pg.cc       |  4 ++--
 7 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/src/coeio.cc b/src/coeio.cc
index 16c53866b2..3cc8b10ee0 100644
--- a/src/coeio.cc
+++ b/src/coeio.cc
@@ -117,9 +117,9 @@ coeio_reinit(void)
 }
 
 static void
-async_on_exec(eio_req *req)
+coio_on_exec(eio_req *req)
 {
-	struct async_task *task = (struct async_task *) req;
+	struct coio_task *task = (struct coio_task *) req;
 	req->result = task->task_cb(task);
 }
 
@@ -128,11 +128,11 @@ async_on_exec(eio_req *req)
  * eio_request is complete.
  */
 static int
-async_on_finish(eio_req *req)
+coio_on_finish(eio_req *req)
 {
-	struct async_task *task = (struct async_task *) req;
+	struct coio_task *task = (struct coio_task *) req;
 	if (task->fiber == NULL) {
-		/* timed out (only async_task() )*/
+		/* timed out (only coio_task() )*/
 		if (task->timeout_cb != NULL) {
 			task->timeout_cb(task);
 		}
@@ -145,14 +145,14 @@ async_on_finish(eio_req *req)
 }
 
 ssize_t
-async_task(struct async_task *task, async_task_cb func,
-	   async_timeout_cb on_timeout, ev_tstamp timeout)
+coio_task(struct coio_task *task, coio_task_cb func,
+	   coio_task_timeout_cb on_timeout, ev_tstamp timeout)
 {
 	/* from eio.c: REQ() definition */
 	memset(&task->base, 0, sizeof(task->base));
 	task->base.type = EIO_CUSTOM;
-	task->base.feed = async_on_exec;
-	task->base.finish = async_on_finish;
+	task->base.feed = coio_on_exec;
+	task->base.finish = coio_on_finish;
 	/* task->base.destroy = NULL; */
 	/* task->base.pri = 0; */
 
@@ -174,9 +174,9 @@ async_task(struct async_task *task, async_task_cb func,
 }
 
 static void
-async_on_call(eio_req *req)
+coio_on_call(eio_req *req)
 {
-	struct async_task *task = (struct async_task *) req;
+	struct coio_task *task = (struct coio_task *) req;
 	req->result = task->call_cb(task->ap);
 }
 
@@ -201,20 +201,20 @@ async_on_call(eio_req *req)
  *	         return open(filename, flags);
  *	}
  *
- *	 if (coeio_custom(openfile_cb, 0.10, "/tmp/file", 0) == -1)
+ *	 if (coio_call(openfile_cb, 0.10, "/tmp/file", 0) == -1)
  *		// handle errors.
  *	...
  */
 ssize_t
-async_call(ssize_t (*func)(va_list ap), ...)
+coio_call(ssize_t (*func)(va_list ap), ...)
 {
-	struct async_task *task = (struct async_task *) calloc(1, sizeof(*task));
+	struct coio_task *task = (struct coio_task *) calloc(1, sizeof(*task));
 	if (task == NULL)
 		return -1; /* errno = ENOMEM */
 	/* from eio.c: REQ() definition */
 	task->base.type = EIO_CUSTOM;
-	task->base.feed = async_on_call;
-	task->base.finish = async_on_finish;
+	task->base.feed = coio_on_call;
+	task->base.finish = coio_on_finish;
 	/* task->base.destroy = NULL; */
 	/* task->base.pri = 0; */
 
@@ -241,7 +241,7 @@ async_call(ssize_t (*func)(va_list ap), ...)
 }
 
 struct async_getaddrinfo_task {
-	struct async_task base;
+	struct coio_task base;
 	struct addrinfo *result;
 	int rc;
 	char *host;
@@ -258,7 +258,7 @@ struct async_getaddrinfo_task {
  * coeio (libeio).
 */
 static ssize_t
-getaddrinfo_cb(struct async_task *ptr)
+getaddrinfo_cb(struct coio_task *ptr)
 {
 	struct async_getaddrinfo_task *task =
 		(struct async_getaddrinfo_task *) ptr;
@@ -282,7 +282,7 @@ getaddrinfo_cb(struct async_task *ptr)
 }
 
 static void
-getaddrinfo_free_cb(struct async_task *ptr)
+getaddrinfo_free_cb(struct coio_task *ptr)
 {
 	struct async_getaddrinfo_task *task =
 		(struct async_getaddrinfo_task *) ptr;
@@ -294,9 +294,9 @@ getaddrinfo_free_cb(struct async_task *ptr)
 }
 
 int
-async_getaddrinfo(const char *host, const char *port,
-		  const struct addrinfo *hints, struct addrinfo **res,
-		  ev_tstamp timeout)
+coio_getaddrinfo(const char *host, const char *port,
+		 const struct addrinfo *hints, struct addrinfo **res,
+		 ev_tstamp timeout)
 {
 	int rc = EAI_SYSTEM;
 	int save_errno = 0;
@@ -324,8 +324,8 @@ async_getaddrinfo(const char *host, const char *port,
 		}
 	}
 	/* do resolving */
-	/* async_task() don't throw. */
-	if (async_task(&task->base, getaddrinfo_cb, getaddrinfo_free_cb,
+	/* coio_task() don't throw. */
+	if (coio_task(&task->base, getaddrinfo_cb, getaddrinfo_free_cb,
 		       timeout) == -1) {
 		/* timed out */
 		errno = ETIMEDOUT;
@@ -356,7 +356,7 @@ int
 cord_cojoin(struct cord *cord)
 {
 	assert(cord() != cord); /* Can't join self. */
-	int rc = async_call(cord_cojoin_cb, cord);
+	int rc = coio_call(cord_cojoin_cb, cord);
 	if (rc == 0 && cord->fiber->exception) {
 		Exception::move(&cord->fiber->exception, &fiber()->exception);
 		cord_destroy(cord);
diff --git a/src/coeio.h b/src/coeio.h
index 5a2488a7f5..d76b272a6f 100644
--- a/src/coeio.h
+++ b/src/coeio.h
@@ -61,25 +61,25 @@ void coeio_reinit(void);
 
 struct coeio_task;
 
-typedef ssize_t (*async_task_cb)(struct async_task *task); /* like eio_req */
-typedef ssize_t (*async_call_cb)(va_list ap);
-typedef void (*async_timeout_cb)(struct async_task *task); /* like eio_req */
+typedef ssize_t (*coio_task_cb)(struct coio_task *task); /* like eio_req */
+typedef ssize_t (*coio_call_cb)(va_list ap);
+typedef void (*coio_task_timeout_cb)(struct coio_task *task); /* like eio_req */
 
 /**
  * A single task context.
  */
-struct async_task {
+struct coio_task {
 	struct eio_req base; /* eio_task - must be first */
 	/** The calling fiber. */
 	struct fiber *fiber;
 	/** Callbacks. */
 	union {
-		struct { /* async_task() */
-			async_task_cb task_cb;
-			async_timeout_cb timeout_cb;
+		struct { /* coio_task() */
+			coio_task_cb task_cb;
+			coio_task_timeout_cb timeout_cb;
 		};
-		struct { /* async_call() */
-			async_call_cb call_cb;
+		struct { /* coio_call() */
+			coio_call_cb call_cb;
 			va_list ap;
 		};
 	};
@@ -88,16 +88,16 @@ struct async_task {
 };
 
 ssize_t
-async_task(struct async_task *task, async_task_cb func,
-	   async_timeout_cb on_timeout, ev_tstamp timeout);
+coio_task(struct coio_task *task, coio_task_cb func,
+	  coio_task_timeout_cb on_timeout, ev_tstamp timeout);
 
 ssize_t
-async_call(ssize_t (*func)(va_list ap), ...);
+coio_call(ssize_t (*func)(va_list ap), ...);
 
 int
-async_getaddrinfo(const char *host, const char *port,
-		  const struct addrinfo *hints, struct addrinfo **res,
-		  ev_tstamp timeout);
+coio_getaddrinfo(const char *host, const char *port,
+		 const struct addrinfo *hints, struct addrinfo **res,
+		 ev_tstamp timeout);
 
 #if defined(__cplusplus)
 }
diff --git a/src/coio.cc b/src/coio.cc
index 70c8614c94..d3c1f2f5f4 100644
--- a/src/coio.cc
+++ b/src/coio.cc
@@ -200,7 +200,7 @@ coio_connect_timeout(struct ev_io *coio, struct uri *uri, struct sockaddr *addr,
 	    hints.ai_socktype = SOCK_STREAM;
 	    hints.ai_flags = AI_ADDRCONFIG|AI_NUMERICSERV|AI_PASSIVE;
 	    hints.ai_protocol = 0;
-	    int rc = async_getaddrinfo(host, service, &hints, &ai, delay);
+	    int rc = coio_getaddrinfo(host, service, &hints, &ai, delay);
 	    if (rc != 0) {
 		ai = NULL;
 	    }
diff --git a/src/lua/bsdsocket.cc b/src/lua/bsdsocket.cc
index e350f4943e..a3c08b5f93 100644
--- a/src/lua/bsdsocket.cc
+++ b/src/lua/bsdsocket.cc
@@ -658,7 +658,7 @@ lbox_bsdsocket_getaddrinfo(struct lua_State *L)
 		lua_pop(L, 1);
 	}
 
-	int dns_res = async_getaddrinfo(host, port, &hints, &result, timeout);
+	int dns_res = coio_getaddrinfo(host, port, &hints, &result, timeout);
 	lua_pop(L, 2);	/* host, port */
 
 	if (dns_res != 0) {
diff --git a/src/lua/init.cc b/src/lua/init.cc
index f6f5b1ebcd..96e998484b 100644
--- a/src/lua/init.cc
+++ b/src/lua/init.cc
@@ -191,7 +191,7 @@ tarantool_console_readline(struct lua_State *L)
 	}
 
 	char *line;
-	if (async_call(readline_cb, &line, prompt) != 0) {
+	if (coio_call(readline_cb, &line, prompt) != 0) {
 		lua_pushnil(L);
 		return 1;
 	}
diff --git a/src/module/mysql/mysql.cc b/src/module/mysql/mysql.cc
index eaefd760c1..3bc120684a 100644
--- a/src/module/mysql/mysql.cc
+++ b/src/module/mysql/mysql.cc
@@ -320,7 +320,7 @@ lua_mysql_execute(struct lua_State *L)
 	sql = lua_tolstring(L, -1, &len);
 
 
-	int res = async_call(exec_mysql, mysql, sql, len);
+	int res = coio_call(exec_mysql, mysql, sql, len);
 	lua_pop(L, 1);
 	if (res == -1)
 		luaL_error(L, "%s", strerror(errno));
@@ -331,7 +331,7 @@ lua_mysql_execute(struct lua_State *L)
 	int resno = 0;
 	do {
 		MYSQL_RES *result = NULL;
-		res = async_call(fetch_result, mysql, &result, resno);
+		res = coio_call(fetch_result, mysql, &result, resno);
 		if (res == -1)
 			luaL_error(L, "%s", strerror(errno));
 
@@ -407,7 +407,7 @@ lbox_net_mysql_connect(struct lua_State *L)
 	}
 
 
-	if (async_call(connect_mysql, mysql, host, port, user, pass, db) == -1) {
+	if (coio_call(connect_mysql, mysql, host, port, user, pass, db) == -1) {
 		mysql_close(mysql);
 		luaL_error(L, "%s", strerror(errno));
 	}
diff --git a/src/module/pg/pg.cc b/src/module/pg/pg.cc
index 4aeae71431..b58ecb1761 100644
--- a/src/module/pg/pg.cc
+++ b/src/module/pg/pg.cc
@@ -282,7 +282,7 @@ lua_pg_execute(struct lua_State *L)
 	}
 
 	PGresult *res = NULL;
-	if (async_call(pg_exec, conn,
+	if (coio_call(pg_exec, conn,
 			sql, count, paramTypes, paramValues,
 			paramLengths, paramFormats, &res) == -1) {
 
@@ -444,7 +444,7 @@ lbox_net_pg_connect(struct lua_State *L)
 
 	const char *constr = lua_tostring(L, -1);
 
-	if (async_call(pg_connect, constr, &conn) == -1) {
+	if (coio_call(pg_connect, constr, &conn) == -1) {
 		luaL_error(L, "Can't connect to postgresql: %s",
 			strerror(errno));
 	}
-- 
GitLab