Atomic operations in glib
- From: "Tomasz Jankowski" <tomcioj gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Atomic operations in glib
- Date: Wed, 10 Dec 2008 23:16:41 +0100
Hello!
I'm working on multithread code, and in some functions I need to access some
variables very often. In result I lock and unlock mutex protecting these
variables all the time. It affects performance very bad.
I figured out, that I can use atomic operation (provided by GLib) to
decrease mutex usage. I can store many things in one volatile gint variable
thanks to bits manipulation.
However I don't know if performing many atomic operations on one variable in
MT code is a good idea. Morover I'd like to know if GLib guarantees, that
atomic operations will be thread safe on all platforms supported by GLib.
Maybe there are some other contraindications, that I should use mutex
protection instead of atomic operations.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]