On Wed, 2007-07-04 at 23:08 +0200, Tomasz Jankowski wrote: > Ok, so I can mix object implementation with GStaticRWLock and make > something like this: > > static void > socket_set_property (GObject *object, guint prop_id, const GValue > *value, GParamSpec *pspec) > { > g_return_if_fail (IS_SOCKET (object)); > > SocketPrivate *priv_data = SOCKET_PRIVATE (SOCKET (object)); > > g_static_rw_lock_writer_unlock (priv_data->rw_mutex); > switch (prop_id) { > /*...*/ > } > g_static_rw_lock_writer_lock (priv_data->rw_mutex); > } > > static void > socket_get_property (GObject *object, guint prop_id, GValue *value, > GParamSpec *pspec) > { > g_return_if_fail (IS_SOCKET (object)); > > SocketPrivate *priv_data = SOCKET_PRIVATE (SOCKET (object)); > > g_static_rw_lock_reader_unlock (priv_data->rw_mutex); > switch (prop_id) { > /*...*/ > } > g_static_rw_lock_reader_lock (priv_data->rw_mutex); > > } > > > I add GStaticRWLock to object's private data. What do you think about > this idea?
A number of points: (a) You have your locks and unlocks the wrong way round (b) The circumstances in which it is right to incur the overhead of a read/write lock instead of using a plain mutex are very limited. (c) Apart from that, if using a read/write lock instead of mutex you would also need to look at the code which gets a property to make sure it does not change any member data in any way (in other words, it supports concurrent unlocked reads). It probably doesn't change member data, but you would need to check. (d) Your scheme will only work (whether using a read/write lock or a mutex) if on every occasion on which a property on the object is set or read, it is done via your specialised functions and not the standard GObject property functions. I do not know enough about GObject to tell you whether that is easily enforced or not, and whether you have chosen the best way to do it. Chris _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list