Use tango.core.Atomic.atomicLoad and atomicStore from Tango

Lukasz Durniat ldurniat at gmail.com
Sun Mar 25 07:31:02 PDT 2012


Here is code:

import Integer = tango.text.convert.Integer;
import tango.math.random.Random;
import tango.core.Thread;
import tango.core.Atomic;

class MyThread :Thread {

	bool* log;

	this( bool* log ) {
	  super(&run);
	  this.log = log;
	}

     void run() {
	   auto rand = new Random();
	
		if( rand.uniformR(2) == 0 ) {
			//atomicStore!(msync.raw, bool)(*log, false);
			//alias  atomicStore!(msync.raw, bool) A;
			//A.atomicStore(*log);
			atomicStore!(msync.acq, bool).atomicStore(log);
	   }
	}
}	

void main(char[][] args) {

	
	int n = Integer.parse(args[1]);
	
	bool log = true;
	
	for(int i = 0; i < n; i++)
		(new MyThread( &log )).start();

}

Here are errors when I compiling program:

Error: function tango.core.Atomic.atomicStore!(cast(msync)5,b
ool,bool) does not match parameter types ()
Error: expected 2 function arguments, not 0
Error: no property 'atomicStore' for type 'void'
Error: function expected before (), not 1 of type int

I dont know what is wrong.



More information about the Digitalmars-d mailing list