std.concurrency.send

2012-05-19 Thread japplegame
Multithreading in D confuses me more and more. import std.concurrency; import std.stdio; shared Tid tid; void main() { send(cast(Tid)tid, "Hello, World"); } void worker() { writeln(receiveOnly!string); } shared static this() { tid = cast(shared)spawn(&worker); } I hate these explicit cast

Re: std.concurrency.send

2012-05-19 Thread Nathan M. Swan
On Saturday, 19 May 2012 at 13:26:20 UTC, japplegame wrote: Multithreading in D confuses me more and more. import std.concurrency; import std.stdio; shared Tid tid; void main() { send(cast(Tid)tid, "Hello, World"); } void worker() { writeln(receiveOnly!string); } shared static this() { ti

Re: std.concurrency.send

2012-05-19 Thread japplegame
You don't need to mark Tids as shared. Okay. I'm writting logger. Logger is global object and it is running in its own separate thread (for example, writting logs to remote database). My application has several threads and all of them want to log something. How to share this global logger between

Re: std.concurrency.send

2012-05-19 Thread Nathan M. Swan
On Saturday, 19 May 2012 at 21:13:14 UTC, japplegame wrote: You don't need to mark Tids as shared. Okay. I'm writting logger. Logger is global object and it is running in its own separate thread (for example, writting logs to remote database). My application has several threads and all of them

Re: std.concurrency.send

2012-05-19 Thread japplegame
public: void startLogger(LogConstructorArgs args) { loggerTid = spawn(&loggerThread, args); } void log(string msg, OtherOptions oo) { loggerTid.send(LogMsg(msg, oo)); } void stopLogger() { loggerTid.send(QuitMsg()); } private: Tid loggerTid; struct LogMsg { string msg; Othe

Re: std.concurrency.send

2012-05-20 Thread Nathan M. Swan
On Sunday, 20 May 2012 at 04:09:50 UTC, japplegame wrote: public: void startLogger(LogConstructorArgs args) { loggerTid = spawn(&loggerThread, args); } void log(string msg, OtherOptions oo) { loggerTid.send(LogMsg(msg, oo)); } void stopLogger() { loggerTid.send(QuitMsg()); } private:

Re: std.concurrency.send

2012-05-24 Thread Sean Kelly
On May 19, 2012, at 2:13 PM, japplegame wrote: >> You don't need to mark Tids as shared. > Okay. I'm writting logger. Logger is global object and it is > running in its own separate thread (for example, writting logs to > remote database). > My application has several threads and all of them want

std.concurrency.send problems with immutable

2015-08-07 Thread Marek Janukowicz via Digitalmars-d-learn
This program works fine: import std.concurrency; struct A { string a,b; } void main () { immutable A a = immutable A( "blah" ); send( thisTid, a ); } But if change struct A declaration to: struct A { string a,b,c; } I get this error during compilation: /opt/dmd2/linux/bin64/../../src

Re: std.concurrency.send problems with immutable

2015-08-07 Thread Ali Çehreli via Digitalmars-d-learn
On 08/07/2015 03:24 PM, Marek Janukowicz wrote:> This program works fine: > > import std.concurrency; > > struct A { >string a,b; > } > > void main () { >immutable A a = immutable A( "blah" ); >send( thisTid, a ); > } > > But if change struct A declaration to: > > struct A { >strin