www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Use tango.core.Atomic.atomicLoad and atomicStore from Tango

reply "Lukasz Durniat" <ldurniat gmail.com> writes:
Hi,

When I use  this function in program I have error during
compiling proccess, so someone can show me how use(example) it in
proper manner - without errors.

I try find some samples  or documentations but this dont help.

Thanks for any help.
Mar 25 2012
parent reply =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= <xtzgzorex gmail.com> writes:
On 25-03-2012 14:49, Lukasz Durniat wrote:
 Hi,

 When I use this function in program I have error during
 compiling proccess, so someone can show me how use(example) it in
 proper manner - without errors.

 I try find some samples or documentations but this dont help.

 Thanks for any help.
You know, we kinda need some code and compiler errors to help you out here. -- - Alex
Mar 25 2012
parent reply "Lukasz Durniat" <ldurniat gmail.com> writes:
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.
Mar 25 2012
parent reply "Lukasz Durniat" <ldurniat gmail.com> writes:
Can somebody tell me what is wrong in my code?
Mar 26 2012
parent reply "Lukasz Durniat" <ldurniat gmail.com> writes:
Problem has been  solved by me.
Mar 26 2012
parent mta`chrono <chrono mta-international.net> writes:
Am 26.03.2012 19:26, schrieb Lukasz Durniat:
 Problem has been  solved by me.
Can you please tell me how you'd solved it?
Mar 29 2012