Which Multithreading Solution?
Hey there! I'm trying to figure out which of D's many multithreading options to use for my application. I'm making a game that runs at 60 frames per second that can also run user-made Lua scripts. I would like to have the Lua scripts run in a separate thread so they can't delay frames if there's a lot of work to do in a burst, but I also need it to be able to update and read from the thread where everything else is. I don't think message passing is going to cut it because the Lua thread is going to need to be able to request to set a value in D on one line, and then request that value back on the next line, and that value needs to be updated at that point, not at the end. I've been marking things as __gshared to get them working, but I think that just makes a copy on all threads, which seems pretty excessive when mostly the Lua will just be reading values, and occasionally calling a function in D to change some values. I think I should try to do some kind of lock thing, but I'm not really sure how that works. If someone could advise me on what tact I should take, that would be very helpful. Thanks!
Error when profiling
When trying to run my program with profiling enabled it dies before the first line of my main function runs. Everything works fine without profiling. I get the following stack trace: thread #1: tid = 0x38de4, 0x00010008d985 vision_entry`gc_malloc + 49, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x00010008d985 vision_entry`gc_malloc + 49 vision_entry`gc_malloc + 49: - 0x10008d985: movq (%rdi), %rbx 0x10008d988: callq *0x60(%rbx) 0x10008d98c: popq %rbx 0x10008d98d: movq %rbp, %rsp (lldb) thread backtrace * thread #1: tid = 0x38de4, 0x00010008d985 vision_entry`gc_malloc + 49, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) * frame #0: 0x00010008d985 vision_entry`gc_malloc + 49 frame #1: 0x0001000908f5 vision_entry`_d_newclass + 117 frame #2: 0x0001000b4b28 vision_entry`D3std9exception7bailOutFNaNfAyamxAaZv + 40 frame #3: 0x0001000b4d06 vision_entry`D3std9exception14__T7enforceTbZ7enforceFNaNfbLAxaAyamZb + 94 frame #4: 0x0001000c4df6 vision_entry`D3std5stdio4File17LockingTextWriter6__ctorMFNcNeKS3std5stdio4FileZS3std5stdio4File17LockingTextWriter + 86 frame #5: 0x0001000c4f19 vision_entry`D3std5stdio4File17lockingTextWriterMFZS3std5stdio4File17LockingTextWriter + 41 frame #6: 0x00012c74 vision_entry`D3std5stdio4File15__T8writeflnTaZ8writeflnMFxAaZv + 124 at stdio.d:1238 frame #7: 0x00010c06 vision_entry`_Dmain + 86 at stdio.d:2727 frame #8: 0x00010009060c vision_entry`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv + 40 frame #9: 0x000100090551 vision_entry`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 45 frame #10: 0x0001000905b1 vision_entry`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 45 frame #11: 0x000100090551 vision_entry`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 45 frame #12: 0x0001000904cd vision_entry`_d_run_main + 433 frame #13: 0x00010d29 vision_entry`main + 65 frame #14: 0x7fff883a45c9 libdyld.dylib`start + 1 Does anyone have any ideas of what could have caused this?
Re: vibe.d error
Bumping as it's still not possible to install lib event via dub. On Sunday, 25 January 2015 at 17:41:38 UTC, Phil wrote: dub init name vibe.d cd name dub Results in Fetching libevent 2.0.1+2.0.16... Error executing command upgrade: Failed to download http://code.dlang.org/packages/libevent/2.0.1%252B2.0.16.zip: 404 Not Found I'm not sure if the error is the file not being there or dub looking there. Is there a workaround for this? Thanks
Re: vibe.d error
I was using 0.9.21. Upgrading has fixed this issue, thanks to you both.
vibe.d error
dub init name vibe.d cd name dub Results in Fetching libevent 2.0.1+2.0.16... Error executing command upgrade: Failed to download http://code.dlang.org/packages/libevent/2.0.1%252B2.0.16.zip: 404 Not Found I'm not sure if the error is the file not being there or dub looking there. Is there a workaround for this? Thanks
Re: Colour operations using CyberShadow's graphics library
Brilliant, thanks a lot. That works a treat, allowing me to use c1 + c2 when c1 :: RGB and c2 :: ChangeChannelType!(RGB, int), say. It's not happy with doubles atm, but presumably this is sorted in your push. Thanks again :-) On Monday, 19 January 2015 at 21:11:34 UTC, Vladimir Panteleev wrote: Hi Phil, The Color template implements opCast for types with the same set of fields, so you should be able to just cast a struct with ubyte fields to one with double fields (or use std.conv.to). The only restriction is that the fields must have the same order. You can use the ChangeChannelType template to create a Color type from an existing one but a different type for the channel fields, for example this assert will hold: static assert(is(ChangeChannelType!(RGB, ushort) == RGB16)); To create a view with double-typed channels from an RGB view, you can use colorMap: alias doubleTypedView = colorMap!(c = cast(ChangeChannelType!(typeof(c), double))c); You can use this as with any other view transform: auto i = onePixel(L8(1)); auto d = i.doubleTypedView(); assert(d[0, 0].l == 1.0); By the way, as I've never tried using floating-point types, the code didn't quite work with them as it is, as some templates expected integral types in a few places. I guess you've fixed things on your side? Anyhow, I've now pushed a commit which fixes and adds tests for FP types.
Re: Colour operations using CyberShadow's graphics library
I've done this by declaring a static array of the same length as ViewColor!V.channels, and foreach-ing over the channels in a colour, but this seem uglier than it need to - it would be nice if I could just define + and = appropriately on double[] and colours to do the right thing. On Sunday, 18 January 2015 at 21:10:05 UTC, Phil wrote: Hi, I'm new to D and having a go at writing some image processing stuff using Vladimir's ae.graphics library. To filter (i.e. perform correlations/convolutions) on a view with colour type C, I'd like to perform intermediate calculations using a colour with the same number of channels as C, but all of type double, and then to convert back to something of type C at the end. e.g. for a horizontal blur I'd like to keep a running total per channel, packaged in an all-doubles colour type, and then write (total / kernel width) for each channel back into a value of type C. How do I perform the necessary type magic here? Thanks
Colour operations using CyberShadow's graphics library
Hi, I'm new to D and having a go at writing some image processing stuff using Vladimir's ae.graphics library. To filter (i.e. perform correlations/convolutions) on a view with colour type C, I'd like to perform intermediate calculations using a colour with the same number of channels as C, but all of type double, and then to convert back to something of type C at the end. e.g. for a horizontal blur I'd like to keep a running total per channel, packaged in an all-doubles colour type, and then write (total / kernel width) for each channel back into a value of type C. How do I perform the necessary type magic here? Thanks
Re: RFC on SlidingSplitter Range
Is prefix ++ preferred in D because of some specific reason? I recall it, for some containers/iterators, gives smaller/faster codegen in C++? I assume the reason is the same as in C++. As users can provide their own implementations of pre and postfix incrementing, the compiler can't assume that x++ always means copy x then increment x and return the copy. It could have arbitrary side effects. Therefore for user defined types x++ can't be replaced with ++x by the compiler even if you're not using the return value. The compiler _can_ do this for primitive types, but as monarch_dodra says, if you get in the habit of using ++x unless you explicitly need x++ then you're never going to suffer and can sometimes get a speed win.
Re: Opening dub packages in Mono-D
mm... is your 'project' a dub package itself? if not, convert it to dub and add it to dependency section in your dub package. then you will be able to open your fresh created project using mono-d with all its dependencies, a bonus you will be able to generate visuald project files too. there is described what to add to include it http://code.dlang.org/packages/pegged Ah right. That works, thanks.
Opening dub packages in Mono-D
I'm trying to use Mono-D, but can't work out how to do simple things. I've tried looking for tutorials but this http://wiki.dlang.org/Mono-D is all I could find. I want to reference Pegged from a Mono-D project. I can't add its package.json as a project to my solution as I'm told that this file in the incorrect format. How should I be doing this, and is there a basic tutorial for idiots available anywhere? Thanks
Debugging on OSX
I've seen a few old threads mentioning this, but couldn't find anything more recent. What support is there for debugging on OSX? I'm currently trying MonoD, but the option to run with debugger is greyed out.