std.concurrency bug?
Charles Hixson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue May 20 17:08:27 PDT 2014
On Tuesday, May 20, 2014 11:42:48 AM Ali Çehreli via Digitalmars-d-learn
wrote:
> On 05/20/2014 11:38 AM, Charles Hixson via Digitalmars-d-learn wrote:
> > Is it a bug that an immutable struct cannot be sent to a thread? (It
> > compiles without problem if I make all elements mutable.)
>
> Does the struct have any mutable indirection? Then it is illegal.
> Otherwise, can you demonstrate with minimal code please?
>
> Ali
Nope. Here it is (with the immutable tags removed):
/** This is the only message that one cell sends to another. */
struct Msg
{ /** The cell id# of the sender of the message. */
uint64_t from;
/** The cell id# of the recipient of the message. */
uint64_t to;
/** The kind of action the message is impelling. */
Act act;
/** The tick on which the message was accepted for transmission.
* This is set by std.datetime.Clock.currStdTime() */
long tick;
/** Distance between cells. Not currently well defined except in
* the case of two words, in which case it is the number of words of
* separation, where adjacent is 1. */
float dist;
/** Not currently well defined. */
int value;
this (uint64_t from, uint64_t to, Act act, float dist, int value)
{ this.from = from;
this.to = to;
this.act = act;
this.tick = Clock.currStdTime;
this.dist = dist;
this.value = value;
}
}
More information about the Digitalmars-d-learn
mailing list