[gnet-dev] Callback arguments in GNet
- From: David Helder <dhelder umich edu>
- To: gnet-dev gnetlibrary org
- Subject: [gnet-dev] Callback arguments in GNet
- Date: Wed, 14 Aug 2002 13:18:11 -0400 (EDT)
I was writing up some documentation on async write and I noticed that GNet
is fairly inconsistent on what should be the arguments in callback.
We seem to do it two ways:
1. Callback includes return value, status, and user data.
Ex:
typedef void (*GInetAddrNewAsyncFunc)(GInetAddr* inetaddr,
GInetAddrAsyncStatus status,
gpointer data);
Associated with:
GInetAddrNewAsyncID
gnet_inetaddr_new_async (const gchar* name, gint port,
GInetAddrNewAsyncFunc func, gpointer data);
Note the callback does not include name and port.
2. Callback includes return value, status, and user data, AS WELL AS
most/all original arguments.
Ex:
typedef void (*GInetAddrGetNameAsyncFunc)(GInetAddr* inetaddr,
GInetAddrAsyncStatus status,
gchar* name,
gpointer data);
Associated with:
GInetAddrGetNameAsyncID
gnet_inetaddr_get_name_async (GInetAddr* ia,
GInetAddrGetNameAsyncFunc func,
gpointer data);
Note the callback includes inetaddr.
My leaning is more to option #1. #1 may be easier for the programmer, but
it requires us to keep a lot more state. Besides, the programmer already
has the data pointer which should be enough. In #2, inetaddr in the
callback is actually a copy of the inetaddr passed in the original
function. (Hmm, really it could be a ref, but then I'd have to add
mutexes.)
Are there any opinions on this? Note I wouldn't make any changes to the
stable API until GNet 1.2 (whenever and whatever that is).
David
--
__ _ __ David Helder - dhelder umich edu
___/ /__ __ __(_)__/ / <http://www.eecs.umich.edu/~dhelder>
/ _ / _ `/ |/ / / _ / Jungle Monkey: <http://www.junglemonkey.net>
|_,_/|_,_/|___/_/|_,_/ Paper CD Case: <http://www.papercdcase.com>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]