Re: External threads calling into D code

2014-06-17 Thread George Sapkin via Digitalmars-d-learn
On Wednesday, 18 June 2014 at 02:35:03 UTC, Ali Çehreli wrote: Without any experience on this topic, I suspect this is what you need: http://dlang.org/phobos/core_thread.html#.thread_attachThis Ali That was exactly what I needed. Thanks.

External threads calling into D code

2014-06-17 Thread George Sapkin via Digitalmars-d-learn
So, me and my threads again :) I have some threads being created by libuv using start_thread() from libpthread calling into D code. D code (after some help from this forum) has been properly shared and when called from D threads and tasks works correctly. However when called by libuv from out

Re: Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-17 Thread George Sapkin via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 17:18:36 UTC, Ali Çehreli wrote: Shared data can be accessed by more than one thread. Unless it is locked, other threads may see the array in an inconsistent state. Ali But that's a local copy of it, no? If it's not, will making a local copy solve this? The origi

Re: Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-17 Thread George Sapkin via Digitalmars-d-learn
Does making an array copy with shared cast away make any sense? auto n = 10; auto sharedData = new shared SomeClass[n]; foreach (i; 0..n) sharedData[i] = new shared SomeClass(i); auto nonSharedData = cast(SomeClass[]) sharedData[0..$]; auto sorted = sort!((a, b) => a.value < b.value)(nonSharedDa

Re: Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-17 Thread George Sapkin via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 04:38:24 UTC, Ali Çehreli wrote: Good news: The code compiles with 2.066 after adding 'import std.algorithm;' :) Ali Thanks, but where can I get 2.066? It seems it's not going to be branched until June 30th. Is there any way to resolve this now with 2.065?

Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-16 Thread George Sapkin via Digitalmars-d-learn
I'm trying to sort shared data with a predicate. Buy that causes 'unable to format shared objects'. Here's an example reproducing the issue without any threading code: shared class SomeClass { immutable int value; this(const int value) { this.value = value; } } void main() {

Node.js async/threads and shared in D

2014-06-11 Thread George Sapkin via Digitalmars-d-learn
I have a Node.js module written in D and exposed through C++ interface. I'd like to implement a proper async API which is pretty straightforward using libuv in the C++ glue part. On the D side I have a data structure that's build once and then queried from Node (possibly torn down and rebuild l

Re: Using D static library from C

2014-06-05 Thread George Sapkin via Digitalmars-d-learn
On Friday, 6 June 2014 at 02:13:08 UTC, Ellery Newcomer wrote: On Thursday, 5 June 2014 at 18:51:25 UTC, George Sapkin wrote: I'm trying to link a simple D static library to C code, but I'm can't figure out how to do it properly without getting a segfault when running it. try this: dmd -lib

Re: Using D static library from C

2014-06-05 Thread George Sapkin via Digitalmars-d-learn
On Friday, 6 June 2014 at 02:01:12 UTC, Mark Isaacson wrote: I found that if I told dmd rather than gcc to do the linking that everything just magically worked. In other words: gcc -c cstuff.c dmd -c dstuff.d dmd cstuff.o dstuff.o I presume that dmd would be similarly smart with static librar

Re: Using D static library from C

2014-06-05 Thread George Sapkin via Digitalmars-d-learn
On Thursday, 5 June 2014 at 19:14:34 UTC, Stefan Koch wrote: On Thursday, 5 June 2014 at 19:00:24 UTC, George Sapkin wrote: On Thursday, 5 June 2014 at 18:55:13 UTC, Stefan Koch wrote: You need to link the druntime too, I think. At which stage? Can you provide a full command? Thanks. Err ..

Re: Using D static library from C

2014-06-05 Thread George Sapkin via Digitalmars-d-learn
On Thursday, 5 June 2014 at 19:14:34 UTC, Stefan Koch wrote: On Thursday, 5 June 2014 at 19:00:24 UTC, George Sapkin wrote: On Thursday, 5 June 2014 at 18:55:13 UTC, Stefan Koch wrote: You need to link the druntime too, I think. At which stage? Can you provide a full command? Thanks. Err ..

Re: Using D static library from C

2014-06-05 Thread George Sapkin via Digitalmars-d-learn
On Thursday, 5 June 2014 at 19:10:17 UTC, Dave Wilson wrote: You can create a static library from one or more .o files using ar, if that helps (unless I've failed to understand the question). "ar r libtest.a test.o" should do the job. I don't have trouble creating a static library with dmd, I

Re: Using D static library from C

2014-06-05 Thread George Sapkin via Digitalmars-d-learn
On Thursday, 5 June 2014 at 18:55:13 UTC, Stefan Koch wrote: You need to link the druntime too, I think. At which stage? Can you provide a full command? Thanks.

Using D static library from C

2014-06-05 Thread George Sapkin via Digitalmars-d-learn
I'm trying to link a simple D static library to C code, but I'm can't figure out how to do it properly without getting a segfault when running it. test.d --- import std.stdio; extern(C) void funcD() { writeln("From D"); } main.c ---