www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Converting from tango.Atomic to D2 core.atomic

reply eris <jvburnes gmail.com> writes:
Hi,

I've been converting 'qtd' (the qt lib interface for D) to ldc / D2 version.
Apparently some areas of the phobos and druntime library are still a little
green for D2 or LDC2 because I'm jumping through some hoops to make it work.

Minor Issues:

1. core.thread is still using 'volatile' instead of 'synchronized'.  Volatile
has been deprecated and you need to tell the compiler to ignore it or the
compile fails.  I'm thinking that a core D2 library should not cause a compile
abort by default.   I got passed it by disabling deprecated checks.

Major Issues:

2. One file in the qtd implementation (QList.d) is using some sort of
lock-free shared list.  Their implementation uses the old tango.core.Atomic
semantics of Atomic! (load, store, increment, decrement).   I've tried
converting these to the equivalent phobos core.atomic and running into some
dead ends.

a) core.atomic implements nearly all binary ops as well as nearly all
assignment / increment ops.  But it doesn't implement the simplest of the ops:
load, store.  Are these assumed to "just work" for ints and doubles?  If so,
fine, but there are platform-dependent gotchas lurking along that path.
Jul 06 2011
next sibling parent reply dsimcha <dsimcha yahoo.com> writes:
== Quote from eris (jvburnes gmail.com)'s article
 a) core.atomic implements nearly all binary ops as well as nearly all
 assignment / increment ops.  But it doesn't implement the simplest of the ops:
 load, store.  Are these assumed to "just work" for ints and doubles?  If so,
 fine, but there are platform-dependent gotchas lurking along that path.

core.atomic does do atomic load/store as of 2.053.
Jul 06 2011
parent KennyTM~ <kennytm gmail.com> writes:
On Jul 6, 11 23:48, dsimcha wrote:
 == Quote from eris (jvburnes gmail.com)'s article
 a) core.atomic implements nearly all binary ops as well as nearly all
 assignment / increment ops.  But it doesn't implement the simplest of the ops:
 load, store.  Are these assumed to "just work" for ints and doubles?  If so,
 fine, but there are platform-dependent gotchas lurking along that path.

core.atomic does do atomic load/store as of 2.053.

Yes there are atomicLoad and atomicStore*, but the documentation on d-p-l.org isn't updated** (it exists in phobos-prerelease*** though). *: https://github.com/D-Programming-Language/druntime/blob/master/src/core/atomic.d#L95 **: http://d-programming-language.org/phobos/core_atomic.html ***: http://d-programming-language.org/phobos-prerelease/core_atomic.html
Jul 06 2011
prev sibling next sibling parent reply Daniel Gibson <metalcaedes gmail.com> writes:
Am 06.07.2011 17:45, schrieb eris:
 Hi,
 
 I've been converting 'qtd' (the qt lib interface for D) to ldc / D2 version.
 Apparently some areas of the phobos and druntime library are still a little
 green for D2 or LDC2 because I'm jumping through some hoops to make it work.
 
 Minor Issues:
 
 1. core.thread is still using 'volatile' instead of 'synchronized'.  Volatile
 has been deprecated and you need to tell the compiler to ignore it or the
 compile fails.  I'm thinking that a core D2 library should not cause a compile
 abort by default.   I got passed it by disabling deprecated checks.
 
 Major Issues:
 
 2. One file in the qtd implementation (QList.d) is using some sort of
 lock-free shared list.  Their implementation uses the old tango.core.Atomic
 semantics of Atomic! (load, store, increment, decrement).   I've tried
 converting these to the equivalent phobos core.atomic and running into some
 dead ends.
 
 a) core.atomic implements nearly all binary ops as well as nearly all
 assignment / increment ops.  But it doesn't implement the simplest of the ops:
 load, store.  Are these assumed to "just work" for ints and doubles?  If so,
 fine, but there are platform-dependent gotchas lurking along that path.
 

Isn't there already a D2 port of QtD? See https://bitbucket.org/qtd/repo/wiki/Home Cheers, - Daniel
Jul 06 2011
parent eris <jvburnes gmail.com> writes:
Yes, but it appears that I must have checked out an earlier version that had
bugs.
 I'm not sure how that happened.  I built it according to the directions on the
qtd page.

After looking at their Atomic.d implementation, I see numerous updates that
should
fix several issues.

I'll re-checkout the sources and see if it helps.
Jul 06 2011
prev sibling parent Sean Kelly <sean invisibleduck.org> writes:
1. The volatile statements should really be converted to atomic ops. I've be=
en lazy about it because it works as-is.=20

2a. There is an atomicLoad and atomicStore in core.atomic. Not sure if it's i=
n the current release though.=20

Sent from my iPhone

On Jul 6, 2011, at 11:45 AM, eris <jvburnes gmail.com> wrote:

 Hi,
=20
 I've been converting 'qtd' (the qt lib interface for D) to ldc / D2 versio=

 Apparently some areas of the phobos and druntime library are still a littl=

 green for D2 or LDC2 because I'm jumping through some hoops to make it wor=

=20
 Minor Issues:
=20
 1. core.thread is still using 'volatile' instead of 'synchronized'.  Volat=

 has been deprecated and you need to tell the compiler to ignore it or the
 compile fails.  I'm thinking that a core D2 library should not cause a com=

 abort by default.   I got passed it by disabling deprecated checks.
=20
 Major Issues:
=20
 2. One file in the qtd implementation (QList.d) is using some sort of
 lock-free shared list.  Their implementation uses the old tango.core.Atomi=

 semantics of Atomic! (load, store, increment, decrement).   I've tried
 converting these to the equivalent phobos core.atomic and running into som=

 dead ends.
=20
 a) core.atomic implements nearly all binary ops as well as nearly all
 assignment / increment ops.  But it doesn't implement the simplest of the o=

 load, store.  Are these assumed to "just work" for ints and doubles?  If s=

 fine, but there are platform-dependent gotchas lurking along that path.
=20

Jul 07 2011