Re: [Vala] volatile



On Thu, 2011-07-28 at 08:31 +0200, Luca Bruno wrote:
On Thu, Jul 28, 2011 at 12:07:47AM +0200, rastersoft wrote:

Hi all:

I'm working with threads, and I need to declare a boolean private
variable as "volatile". I tried with "private volatile bool myvar",
and valide seems to recognize the syntax, but the compilation returns
an error.

Sorry for replying in such way but the original message displays as
empty in evolution :(

Remember that the marking variable as volatile in C does not make it
atomic. You still need something like:

volatile int i = 0;

// if (i)
if (GLib.AtomicInt.get(ref i) != 0)
  ..

// i = true;
GLib.AtomicInt.set(ref i, 1);

http://en.wikipedia.org/wiki/Volatile_variable#In_C_and_C.2B.2B

(I'm sorry if you do know that but either a) you do something
complicated and you need it b) you don't know that)

Regards

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]