Re: Throw an exception but "hide" the top frame?

2014-12-24 Thread Sean Kelly via Digitalmars-d-learn
The backtrace code has a parameter that lets you tell it how many leading frames you want it to skip when generating the result. This is to get out of the Throwable ctor code itself, but it wouldn't be hard to bump this by one or two if you need it to.

Re: detaching a thread from druntime <2.067

2014-12-16 Thread Sean Kelly via Digitalmars-d-learn
On Tuesday, 16 December 2014 at 04:56:10 UTC, Ellery Newcomer wrote: If I have a thread that I need to detach from druntime, I can call thread_detachInstance, but for 2.066, this function does not exist. Is there any way to do this in 2.066? I notice there is a thread_detachByAddr, but I'm not

Re: How to use Linux message queues?

2014-11-14 Thread Sean Kelly via Digitalmars-d-learn
Sounds like a module that should be in core.sys.linux. Care to submit a pull request?

Re: ODBC Library?

2014-11-10 Thread Sean Kelly via Digitalmars-d-learn
Oh, here's a sample, since it doesn't look like that zip includes one: import sql.Connection; import sql.Exception; import sql.ResultSet; import sql.Statement; import core.stdc.stdio; pragma( lib, "odbc32.lib" ); pragma( lib, "sql.lib" ); void main() { try { auto conn = new

Re: ODBC Library?

2014-11-10 Thread Sean Kelly via Digitalmars-d-learn
On Monday, 10 November 2014 at 16:01:21 UTC, Charles wrote: Hi guys, I've been looking and haven't found any libraries for ODBC or MSSQL. I saw some for D v1, but nothing for v2. Anyone know of any, or anyone know of a tutorial that I could use to create this myself? Assuming you're using O

Re: druntime vararg implementation

2014-11-05 Thread Sean Kelly via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 09:45:50 UTC, Mike wrote: Greetings, In core.varar. (https://github.com/D-Programming-Language/druntime/blob/master/src/core/vararg.d), why is the X86 implementation singled out and written in D rather than leveraging the standard c library implementation lik

Re: spawnProcess() not child?

2014-11-03 Thread Sean Kelly via Digitalmars-d-learn
On Monday, 3 November 2014 at 14:09:21 UTC, Steven Schveighoffer wrote: From OP's code, he is on Windows. I believe on Windows you have to sort out some kind of permissions to terminate a process. No idea if std.process does this, but it sounds like probably not.

Re: Question about eponymous template trick

2014-11-03 Thread Sean Kelly via Digitalmars-d-learn
On Monday, 3 November 2014 at 14:58:03 UTC, Ali Çehreli wrote: I think it's the intended behavior. I think documentation is outdated. Both forms should really work though. I had always thought that the short form was simply possible if the names matched.

Re: API hooking in Dlang?

2014-11-03 Thread Sean Kelly via Digitalmars-d-learn
On Monday, 3 November 2014 at 04:31:40 UTC, Dirk wrote: I should of mentioned that I have also seen the MadCodeHook Library bindings, which is great but the MCH library is very expensive. Weird, it used to be open source and free.

Re: How are theads, Tid and spawn related?

2014-11-02 Thread Sean Kelly via Digitalmars-d-learn
For those cases you could use spawnLinked and then receive LinkTerminated as well, if you're looking for a solution within the concurrency API.

Re: D int and C/C++ int etc not really compatible when interfacing to C/C++

2014-11-02 Thread Sean Kelly via Digitalmars-d-learn
On Sunday, 2 November 2014 at 16:53:06 UTC, ponce wrote: c_long and c_ulong get used, should c_int and c_uint too in bindings? Looks like fringe use case. On common 32 and 64-bit platforms, the only type whose size changed between 32 and 64 bits is long, so the other aliases were deemed un

Re: How are theads, Tid and spawn related?

2014-11-02 Thread Sean Kelly via Digitalmars-d-learn
On Sunday, 2 November 2014 at 06:23:38 UTC, Ali Çehreli wrote: On 11/01/2014 11:13 PM, Sean Kelly wrote: > Note that thread_joinAll is called automatically when main exits Has that always been the case? I remember having to inject thread_joinAll() calls at the ends of the main()s of a cou

Re: D int and C/C++ int etc not really compatible when interfacing to C/C++

2014-11-02 Thread Sean Kelly via Digitalmars-d-learn
On Sunday, 2 November 2014 at 11:59:27 UTC, Marc Schütz wrote: On Saturday, 1 November 2014 at 21:00:54 UTC, Kagamin wrote: D claims compatibility with system C compiler, which usually have 32-bit int. ... and for C/C++ long which can be 32 or 64 bit, DMD recently introduced the types c_long

Re: How are theads, Tid and spawn related?

2014-11-01 Thread Sean Kelly via Digitalmars-d-learn
Note that thread_joinAll is called automatically when main exits, so if you just want to be sure that your spawned thread completes you don't have to do anything at all. The decision to obscure the Thread object in std.concurrency was deliberate, as it allows us to use more than just kernel threa

Re: How are theads, Tid and spawn related?

2014-11-01 Thread Sean Kelly via Digitalmars-d-learn
Note that thread_joinAll is called automatically when main exits, so if you just want to be sure that your spawned thread completes you don't have to do anything at all. The decision to obscure the Thread object in std.concurrency was deliberate, as it allows us to use more than just kernel th

Re: Problems with Mutex

2014-10-28 Thread Sean Kelly via Digitalmars-d-learn
On Monday, 27 October 2014 at 19:13:13 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: The reason that it's not shared is because Sean Kelly didn't want to make much of anything in druntime shared until shared was better ironed out, which keeps getting talked about but never d

Re: new(malloc) locks everything in multithreading

2014-10-24 Thread Sean Kelly via Digitalmars-d-learn
On Friday, 24 October 2014 at 21:02:05 UTC, Kapps wrote: Yes, GDB is stopping on SIGUSR1 / SIGUSR2 since that's the default settings. D's GC uses these signals for suspending / resuming threads during a collection. You need to type what I said above, prior to typing 'run'. I took a look at

Re: m_condition.mutex cannot be used in shared method ?

2014-10-20 Thread Sean Kelly via Digitalmars-d-learn
On Monday, 20 October 2014 at 09:53:23 UTC, Marco Leise wrote: Thank you for that honest response. The situation is really bizarre. I just tried to create a shared worker thread and there is no ctor in Thread that creates a shared instance. Is a shared constructor even meaningful? [1] If we w

Re: m_condition.mutex cannot be used in shared method ?

2014-10-19 Thread Sean Kelly via Digitalmars-d-learn
On Sunday, 19 October 2014 at 13:42:05 UTC, Marco Leise wrote: I have a thread that is shared by others, so I have a shared method, inside of which I wrote: final void opOpAssign(string op : "~")(ref StreamingObject item) shared { synchronized (m_condition.mutex) {

Re: how to get the \uxxxx unicode code from a char

2014-10-16 Thread Sean Kelly via Digitalmars-d-learn
On Tuesday, 14 October 2014 at 20:08:03 UTC, Brad Anderson wrote: On Tuesday, 14 October 2014 at 20:05:07 UTC, Brad Anderson wrote: https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L579 Oops. Linked the the parser section. I actually don't see any unicode escape encoder

Re: how to get the \uxxxx unicode code from a char

2014-10-14 Thread Sean Kelly via Digitalmars-d-learn
On Tuesday, 14 October 2014 at 19:47:00 UTC, jicman wrote: Greetings. Imagine this code, char[] s = "ABCabc"; foreach (char c; s) { // how do I convert c to something an Unicode code? ie. \u. } I'd look at the JSON string encoder.

Re: A few questions regarding GC.malloc

2014-09-25 Thread Sean Kelly via Digitalmars-d-learn
On Thursday, 25 September 2014 at 21:43:53 UTC, monarch_dodra wrote: On Thursday, 25 September 2014 at 20:58:29 UTC, Gary Willoughby wrote: A few questions regarding GC.malloc. When requesting a chunk of memory from GC.malloc am i right in assuming that this chunk is scanned for pointers to ot

Re: GC can collect object allocated in function, despite a pointer to the object living on?

2014-08-16 Thread Sean Kelly via Digitalmars-d-learn
Interface and object variables are reference types--you don't need the '*' to make them so. By adding the extra layer of indirection you're losing the only reference the GC can decipher to the currentState instance.

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-15 Thread Sean Kelly via Digitalmars-d-learn
On Friday, 15 August 2014 at 20:17:51 UTC, Carl Sturtivant wrote: On Friday, 15 August 2014 at 15:40:35 UTC, Sean Kelly wrote: I thought it did, but apparently the behavior of VirtualAlloc and mmap (which Fiber uses to allocate the stack) simply reserves the range and then commits it lazily

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-15 Thread Sean Kelly via Digitalmars-d-learn
On Friday, 15 August 2014 at 15:25:23 UTC, Dicebot wrote: No, I was referring to the proposal to supply bigger stack size to Fiber constructor - AFAIR it currently does allocate that memory eagerly (and does not use any OS CoW tools), doesn't it? I thought it did, but apparently the behavior

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-15 Thread Sean Kelly via Digitalmars-d-learn
At least on OSX, it appears that mapping memory is constant time regardless of size, but there is some max total memory I'm allowed to map, presumably based on the size of a vmm lookup tabe. The max block size I can allocate is 1 GB, and I can allocate roughly 131,000 of these blocks before ge

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-15 Thread Sean Kelly via Digitalmars-d-learn
On Friday, 15 August 2014 at 14:26:28 UTC, Sean Kelly wrote: On Friday, 15 August 2014 at 08:36:34 UTC, Kagamin wrote: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366887%28v=vs.85%29.aspx Allocates memory charges (from the overall size of memory and the paging files on disk) for

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-15 Thread Sean Kelly via Digitalmars-d-learn
On Friday, 15 August 2014 at 14:28:34 UTC, Dicebot wrote: Won't that kind of kill the purpose of Fiber as low-cost context abstraction? Stack size does add up for thousands of fibers. As long as allocation speed is fast for large allocs (which I have to test), I want to change the default s

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-15 Thread Sean Kelly via Digitalmars-d-learn
On Friday, 15 August 2014 at 08:36:34 UTC, Kagamin wrote: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366887%28v=vs.85%29.aspx Allocates memory charges (from the overall size of memory and the paging files on disk) for the specified reserved memory pages. The function also guarant

Re: What hashing algorithm is used for the D implementation of associative arrays?

2014-08-14 Thread Sean Kelly via Digitalmars-d-learn
Superfast. Though Murmur has gotten good enough that I'm tempted to switch. At the time, Murmur didn't even have a license so it wasn't an option.

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-14 Thread Sean Kelly via Digitalmars-d-learn
On 64 bit, reserve a huge chunk of memory, set a SEGV handler and commit more as needed. Basically how kernel thread stacks work. I've been meaning to do this but haven't gotten around to it yet.

Re: Deprecation: Read-modify-write operations are not allowed for shared variables

2014-08-12 Thread Sean Kelly via Digitalmars-d-learn
On Tuesday, 12 August 2014 at 15:06:38 UTC, ketmar via Digitalmars-d-learn wrote: besides, using atomic operations will allow you to drop synchronize altogether which makes your code slightly faster. ... and potentially quite broken. At the very least, if this value is ready anywhere you'll

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Sean Kelly via Digitalmars-d-learn
On Monday, 4 August 2014 at 21:19:14 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: Has anyone used (the fiber/taks of) vibe.d for something other than powering websites? https://github.com/D-Programming-Language/phobos/pull/1910

Re: Unexpected memory reuse

2014-07-31 Thread Sean Kelly via Digitalmars-d-learn
On Thursday, 31 July 2014 at 19:28:24 UTC, Marc Schütz wrote: On Thursday, 31 July 2014 at 18:30:41 UTC, Anonymous wrote: module test; import std.stdio; class buffer(T, size_t sz) { auto arr = new T[sz]; This allocates an array with `sz` elements once _at compile time_, places it som

Re: Unexpected memory reuse

2014-07-31 Thread Sean Kelly via Digitalmars-d-learn
This looks like an optimizer bug. Do you see the same result with -release set vs. not, etc?

Re: Linux Dynamic Loading of shared libraries

2014-07-29 Thread Sean Kelly via Digitalmars-d-learn
On Monday, 10 March 2014 at 11:59:20 UTC, Steve Teale wrote: Note that there is no call to Runtime.unloadLibrary(). The assumption her is that once the plugin has been loaded it will be there for the duration of the program. If you want to unload it you'll probably have to make sure the plugi

Re: spawn and wait

2014-07-03 Thread Sean Kelly via Digitalmars-d-learn
On Thursday, 3 July 2014 at 10:25:41 UTC, Bienlein wrote: There is also a Semaphore and Barrier class: http://dlang.org/phobos/core_sync_barrier.html http://dlang.org/phobos/core_sync_semaphore.html This is probably what I'd do, though both this and thread_joinAll will only work if you have on

Re: Thread-safety and lazy-initialization of libraries

2014-07-01 Thread Sean Kelly via Digitalmars-d-learn
On Monday, 30 June 2014 at 20:53:25 UTC, Sergey Protko wrote: Is there any proper way to do on-demand lazy-initialization of used library, which will be also thread-safe? How do i need to handle cases where some methods, which requires library to be initialized, called from different threads

Re: What is best way to communicate between computer in local network ?

2014-06-28 Thread Sean Kelly via Digitalmars-d-learn
On Saturday, 28 June 2014 at 17:11:51 UTC, Russel Winder via Digitalmars-d-learn wrote: Sadly, I don't have time to contribute to any constructive work on this just now. And I ought to be doing a review and update to std.parallelism… That's fine. I have zero free time until August.

Re: What is best way to communicate between computer in local network ?

2014-06-28 Thread Sean Kelly via Digitalmars-d-learn
On Friday, 27 June 2014 at 13:03:20 UTC, John Colvin wrote: It's an application and network dependant decision, but I would suggest http://code.dlang.org/packages/zmqd as suitable for most situations. Yeah, this would be my first choice. Or HTTP if integration with other applications is an

Re: GC.calloc(), then what?

2014-06-27 Thread Sean Kelly via Digitalmars-d-learn
On Friday, 27 June 2014 at 07:34:55 UTC, safety0ff wrote: On Friday, 27 June 2014 at 07:03:28 UTC, Ali Çehreli wrote: 1) After allocating memory by GC.calloc() to place objects on it, what else should one do? Use std.conv.emplace. And possibly set BlkInfo flags to indicate whether the block

Re: HeadUnshared in core.atomic

2014-06-12 Thread Sean Kelly via Digitalmars-d-learn
On Thursday, 12 June 2014 at 05:29:39 UTC, Mike Franklin wrote: Hello, I was recently exposed to this template in core.atomic: private { template HeadUnshared(T) { static if( is( T U : shared(U*) ) ) alias shared(U)* HeadUnshared; else alias T Hea

Re: std.concurrency bug?

2014-05-22 Thread Sean Kelly via Digitalmars-d-learn
On Wednesday, 21 May 2014 at 20:19:32 UTC, Ali Çehreli wrote: I think this is a known issue with immutable and Variant, which std.concurrency uses for unknown messages. This looks related: https://issues.dlang.org/show_bug.cgi?id=5538 std.concurrency actually uses Variant as the transport

Re: Attach and detach C threads to D runtime

2014-05-22 Thread Sean Kelly via Digitalmars-d-learn
On Thursday, 22 May 2014 at 19:21:26 UTC, David Soria Parra via Digitalmars-d-learn wrote: I know that thread_detachByAddr exists, but the Thread object from Thread.getAll or Thread.opApply doesn't expose the thread address. Would thread_detachThis work for you? Alternately, you can use pt

Re: Mixing messages and socket operations

2014-03-11 Thread Sean Kelly
On Tuesday, 11 March 2014 at 14:44:51 UTC, Andre Kostur wrote: Hi, I'm trying a prototype project at work and have been trying to find a good example of network programming in D. What I'm trying to do is have a separate thread to deal with the socket (calls .accept() for example), but I'd also

Re: Allocating memory from library

2014-03-08 Thread Sean Kelly
The GC will only scan through and try to ECG memory that it owns. So that's safe.

Re: Nobody understands templates?

2014-03-04 Thread Sean Kelly
On Friday, 28 February 2014 at 18:42:57 UTC, Steve Teale wrote: All the D aficionados seem to wet their pants over meta-programming, but I struggle to find a place to use it. IIRC, I used it in a couple of places when I was trying to write library stuff for MySQL, but in my current project, I us

Re: Mutexes and locking

2014-03-04 Thread Sean Kelly
For what it's worth, you can also do: auto m = new Mutex; sycnchronized (m) { // do stuff } The synchronized block will call lock on enter and unlock on exit, even as a result of a throw.

Re: Custom default exception handler?

2014-02-12 Thread Sean Kelly
On Wednesday, 12 February 2014 at 22:42:45 UTC, Nick Sabalausky wrote: Hmm, that still isn't getting called for me either: void toString(scope void delegate(in char[]) sink) const { import std.stdio; writeln("In Fail.toString()"); sink("someapp: ERROR: "~msg); } Tried on both 2.064.2 and 2

Re: Custom default exception handler?

2014-02-12 Thread Sean Kelly
On Wednesday, 12 February 2014 at 03:31:38 UTC, Nick Sabalausky wrote: Hmm, my custom toString isn't being executed. Am I doing something wrong here? Same result if I inherit direct from Throwable instead of Exception. class Fail : Exception { private this() { super(null);

Re: Custom default exception handler?

2014-02-12 Thread Sean Kelly
On Wednesday, 12 February 2014 at 02:41:34 UTC, Nick Sabalausky wrote: On 2/11/2014 6:35 PM, Sean Kelly wrote: Throw a static exception (maybe even derived directly from Throwable), I assume then that throwing something directly derived from Throwable would still run cleanup code (like scope

Re: Custom default exception handler?

2014-02-11 Thread Sean Kelly
On Wednesday, 12 February 2014 at 01:07:31 UTC, Nick Sabalausky wrote: Oh, interesting. Is this something that can be relied on long-term? Ie, is a static non-Exception Throwable deliberately *supposed* to not include a stack trace, or is it potentially more of a currently-missing feature?

Re: Custom default exception handler?

2014-02-11 Thread Sean Kelly
Throw a static exception (maybe even derived directly from Throwable), similar to OutOfMemory, with a custom toString. That should eliminate the formatting you don't like and will prevent the trace from occurring as well (see rt/deh.d in Druntime--the trace isn't run if you throw typeid(t).ini

Re: std.prelude vs core library

2014-01-17 Thread Sean Kelly
Another small reason is to enforce decoupling between required code and the rest of the library. Back when Phobos was all one library, half the library was compiled into every program. The runtime writes to stderr, the IO package relies on other modules... Kind of like what happens now if you

Re: libphobos.so and loading libraries at runtime

2014-01-07 Thread Sean Kelly
On Sunday, 5 January 2014 at 20:47:44 UTC, FreeSlave wrote: import core.runtime; int main() { Runtime.loadLibrary("does not care"); Runtime.unloadLibrary(null); return 0; } When I try to compile this code with 'dmd main.d', I get errors main.o: In function `_D4core7runtime7Runtime

Re: Current size of GC memory

2013-11-05 Thread Sean Kelly
On Tuesday, 5 November 2013 at 20:19:03 UTC, Namespace wrote: And what is with the return type? It's a struct. You must import it. You don't have to import it. The layout of the struct isn't going to change any time soon. Just copy/paste the definition into your code. Or import it if you

Re: Current size of GC memory

2013-11-05 Thread Sean Kelly
On Monday, 4 November 2013 at 22:25:14 UTC, Rainer Schuetze wrote: On 04.11.2013 11:23, Namespace wrote: And how can I use it? import gc.proxy; doesn't work. You need to add /src/druntime/src to the import search paths. Or simply declare the extern (C) function in your code.

Re: val.init

2013-10-02 Thread Sean Kelly
On Oct 1, 2013, at 7:10 PM, Nick Sabalausky wrote: > I thought variable.init was different from T.init and gave the value of > the explicit initializer if one was used. Was I mistaken?: > > import std.stdio; > void main() > { > int a = 5; > writeln(a.init); // Outputs 0, not 5 > }

Re: GC.collect bug ?

2013-09-17 Thread Sean Kelly
On Sep 17, 2013, at 4:14 AM, Temtaime wrote: > I cannot use the delete/destroy. I want to call dtor at all unreferenced > objects. > Manual from Dlang size says that GC.collect triggers a full collection. But > it doesn't. It does. But the collector isn't guaranteed to collect everything that

Re: Exception chaining

2013-09-13 Thread Sean Kelly
On Sep 13, 2013, at 2:14 PM, monarch_dodra wrote: > In one of my exception handling blocks, I call some code that could *also*, > potentially throw (it's actually a loop, where each iteration can throw, but > I have to do them *all*, meaning I need to handle *several* extra > exceptions). I'm

Re: wmemchar for unix

2013-08-27 Thread Sean Kelly
On Aug 26, 2013, at 11:57 PM, monarch_dodra wrote: > For performance reasons, I need a "w" version of memchr. > > C defines wmemchr as: > wchar_t * wmemchr ( const wchar_t *, wchar_t, size_t ); > > Unfortunatly, on unix, "wchar_t" is defined a *4* bytes long, > making wmemchr, effectivelly, "dm

Re: Associative array key order

2013-08-23 Thread Sean Kelly
On Jul 31, 2013, at 7:55 AM, Dicebot wrote: > On Wednesday, 31 July 2013 at 14:43:21 UTC, Daniel Kozak wrote: >> is there a way for AA to behave same as PHP? > > I doubt it. This snippet suggests that AA's in PHP are not simply AA's and do > additionally track insertion order (or use some simil

Re: Getting number of messages in MessageBox

2013-08-06 Thread Sean Kelly
On Aug 6, 2013, at 1:27 PM, Dmitry Olshansky wrote: > 06-Aug-2013 03:18, Marek Janukowicz пишет: >> I'm using std.concurrency message passing and I'd like to check which thread >> might be a bottleneck. The easiest would be check number of messages piled >> up for each of them, but I could not fi

Re: Getting number of messages in MessageBox

2013-08-06 Thread Sean Kelly
On Aug 5, 2013, at 4:18 PM, Marek Janukowicz wrote: > I'm using std.concurrency message passing and I'd like to check which thread > might be a bottleneck. The easiest would be check number of messages piled > up for each of them, but I could not find a way to do that. Is it possible? > Every

Re: Async messages to a thread.

2013-07-29 Thread Sean Kelly
On Jul 29, 2013, at 10:07 AM, lindenk wrote: > After a bit more research it looks like everyone else uses - > > while(checkIfRunning()) > { >// block with timeout > } > > which leads me to believe this might not be possible or standard. Although, > should something along the lines of this

Re: Async messages to a thread.

2013-07-29 Thread Sean Kelly
On Jul 29, 2013, at 8:28 AM, lindenk wrote: > > Ah, no I mean, what if do_some_blocking_function blocks for some > indeterminate amount of time. I would like it to exit even when it is > currently blocking (as it could be unpredictable when it will stop blocking). Execute the blocking function

Re: Do threads 'end' themselves using core.thread?

2013-07-22 Thread Sean Kelly
On Jul 22, 2013, at 10:25 AM, Alex Horvat wrote: > On Monday, 22 July 2013 at 16:58:00 UTC, Sean Kelly wrote: >> On Jul 22, 2013, at 9:45 AM, "Alex Horvat" wrote: >> >>>> >>>> When a detached thread terminates, its resources are

Re: Do threads 'end' themselves using core.thread?

2013-07-22 Thread Sean Kelly
On Jul 22, 2013, at 9:45 AM, "Alex Horvat" wrote: >> >> When a detached thread terminates, its resources are auto- matically >> released back to the system:" > > Sounds like I can call Thread.getThis().thread_detachThis() from within > DelayedHideTitle() and that will make the thread deta

Re: Do threads 'end' themselves using core.thread?

2013-07-22 Thread Sean Kelly
On Jul 20, 2013, at 12:34 PM, Alex Horvat wrote: > If I use core.thread.Thread to create a new thread associated to a function > like this: > > Thread testThread = new Thread(&DoSomething); > > Will the testThread dispose of itself after DoSomething() completes, or do I > need to join/destroy

Re: Do threads 'end' themselves using core.thread?

2013-07-22 Thread Sean Kelly
On Jul 22, 2013, at 9:15 AM, Ali Çehreli wrote: > > Apparently, it is possible to detach from a thread or even to start it in the > detached state to begin with: "By default, a new thread is created in a > joinable state, unless attr was set to create the thread in a detached state > (using pt

Re: Passing a class instance to a thread via spawn()

2013-07-18 Thread Sean Kelly
On Jul 18, 2013, at 4:23 PM, Joseph Rushton Wakeling wrote: > Hello all, > > I have a data structure which is a final class. Once created, the contents of > the class will not be mutated (only its const methods will be called). > > Is there any way to pass this to a thread via spawn() or via

Re: concurrency problem with pointers

2013-07-18 Thread Sean Kelly
On Jul 18, 2013, at 8:29 AM, evilrat wrote: > > shortly speaking, WINDOW is pointer to window in C library so it's "shared", > and i need it in another thread to make opengl context current in that > thread, but compiler simply doesn't allow me to do anything with that, and i > can't change de

Re: inverse of std.demangle?

2013-07-11 Thread Sean Kelly
On Jul 11, 2013, at 10:00 AM, "Adam D. Ruppe" wrote: > BTW if you guys are wondering how I found the allocations, it was pretty > simple: > > dmd mangle.d -debug -gc > gdb ./mangle > > break gc_malloc > break gc_qalloc > r > > > Then when it breaks, do "where" and see what called the gc allo

Re: inverse of std.demangle?

2013-07-11 Thread Sean Kelly
On Jul 11, 2013, at 9:56 AM, Adam D. Ruppe wrote: > On Thursday, 11 July 2013 at 16:38:48 UTC, Jacob Carlborg wrote: >> enum string[23] _primitives = [ ... ]; >> static immutable primitives = _primitives; > > Cool, a variant of that did work. Thanks! > > Now it is 100% heap allocation free. Sw

Re: pointers, assignments, Garbage Collection Oh My?

2013-07-10 Thread Sean Kelly
On Jul 10, 2013, at 10:45 AM, Namespace wrote: >> A string in D, and all arrays, is a struct looking like this: >> >> struct Array (T) >> { >>T* ptr; >>size_t length; >> } > > I always thought it looks like this: > > struct Array(T) { >T* ptr; >size_t length, capacity; > } Sad

Re: inverse of std.demangle?

2013-07-10 Thread Sean Kelly
On Jul 10, 2013, at 10:44 AM, Timothee Cour wrote: > Thanks much, that's a good start. > Template support would definitely be needed as it's so common. > This should go in std.demangle (or maybe a new std.mangle) core.mangle/demangle. It would have to be done in a way that avoided allocating t

Re: Assert failures in threads

2013-07-09 Thread Sean Kelly
On Jul 9, 2013, at 3:33 PM, Jonathan M Davis wrote: > On Tuesday, July 09, 2013 10:39:59 Sean Kelly wrote: >> If you join the thread, any unhanded exception will be rethrown in the >> joining thread by default. > > What about threads which were spawned by std.concurr

Re: Assert failures in threads

2013-07-09 Thread Sean Kelly
On Jul 1, 2013, at 4:04 AM, Joseph Rushton Wakeling wrote: > I've noticed that when an assert fails inside a thread, no error message is > printed and the program/thread just hangs. > > Is there any way to ensure that an assertion failure inside a thread does > output > a message? For the pur

Re: Can someone give me a little program design advice please?

2013-06-19 Thread Sean Kelly
On Jun 19, 2013, at 12:54 PM, Ali Çehreli wrote: > On 06/19/2013 11:46 AM, Sean Kelly wrote: > > > Thread.sleep(dur!"msecs"(300)); > > Totally unrelated but there has been some positive changes. :) The following > is much better: > >

Re: Can someone give me a little program design advice please?

2013-06-19 Thread Sean Kelly
On Jun 16, 2013, at 8:27 AM, Gary Willoughby wrote: > I'm writing a little program in D to perform some database operations and > have a small question about design. > > Part of my program watches a log file for changes and this involves code > which is wrapped up in a class. So the usage is s

Re: GC dead-locking ?

2013-06-18 Thread Sean Kelly
On Jun 18, 2013, at 7:01 AM, Marco Leise wrote: > Am Mon, 17 Jun 2013 10:46:19 -0700 > schrieb Sean Kelly : > >> On Jun 13, 2013, at 2:22 AM, Marco Leise wrote: >> >>> Here is an excerpt from a stack trace I got while profiling >>> with OProfil

Re: Mac OS crash, details inside...

2013-06-17 Thread Sean Kelly
On Jun 14, 2013, at 2:49 AM, Gary Willoughby wrote: > In fact i have the same problem reading files too. It only reads files up to > a certain amount of bytes then crashes in the same manner explained above. > Again this only happens when the program runs as a daemon. Run as a daemon how?

Re: GC dead-locking ?

2013-06-17 Thread Sean Kelly
On Jun 13, 2013, at 2:22 AM, Marco Leise wrote: > Here is an excerpt from a stack trace I got while profiling > with OProfile: > > #0 sem_wait () from /lib64/libpthread.so.0 > #1 thread_suspendAll () at core/thread.d:2471 > #2 gc.gcx.Gcx.fullcollect() (this=...) at gc/gcx.d:2427 > #3 gc.gcx.

Re: Fibers vs Async/await

2013-06-17 Thread Sean Kelly
Fibers don't actually execute asynchronously. They represent an alternate execution context (code and stack) but are executed by the thread that calls them, and control is returned when they either yield or complete. This video is a good introduction to fibers: http://vimeo.com/1873969 On Ju

Re: What sync object should i use?

2013-05-15 Thread Sean Kelly
On Wednesday, 15 May 2013 at 15:35:05 UTC, Juan Manuel Cabo wrote: It sounds like you need to: 1) use a Message Queue. 2) Copy the message while you work on it with the consumer, so that you can exit the mutex. At which point I'll suggest considering std.concurrency instead of rollin

Re: What sync object should i use?

2013-05-14 Thread Sean Kelly
On May 14, 2013, at 12:02 PM, Dmitry Olshansky wrote: > 14-May-2013 21:02, Steven Schveighoffer пишет: >> >> But since you have to lock anyway, signaling while holding the lock, or >> while being outside the lock isn't really a difference. >> > > On the level of gut feeling there must be somet

Re: What sync object should i use?

2013-05-14 Thread Sean Kelly
On May 14, 2013, at 10:59 AM, Heinz wrote: > Guys, this is a precise example of what i'm trying to do. You'll notice that > there're 2 ways of waking up the consumer: > > / > Condition cond; // Previously instantiated. > bool l

Re: What sync object should i use?

2013-05-14 Thread Sean Kelly
On May 14, 2013, at 9:09 AM, Heinz wrote: > On Monday, 13 May 2013 at 21:04:23 UTC, Juan Manuel Cabo wrote: > >> There is one thing that should definitely added to the documentation, and >> that is what happens when one issues a notify while the thread hasn't yet >> called Condition.wait(). >

Re: What sync object should i use?

2013-05-14 Thread Sean Kelly
I'm doing this from my phone so please bear with me. You use a mutex in combination with a condition variable so you can check the state of something to determine if waiting is necessary. So the classic producer/consumer would be something like: T get() { shnchronized(c.mutex) {

Re: Tricky code with exceptions

2013-05-09 Thread Sean Kelly
For what it's worth, this runs fine on 64-bit OSX.

Re: Dispatching values to handlers, as in std.concurrency

2013-05-06 Thread Sean Kelly
On May 6, 2013, at 10:03 AM, "Luís.Marques" "@puremagic.com wrote: > > How can I also accept subclasses? How are the messages stored? std.concurrency uses Variant.convertsTo.

Re: WinAPI callbacks and GC

2013-05-06 Thread Sean Kelly
On May 2, 2013, at 6:17 AM, Regan Heath wrote: > On Wed, 01 May 2013 01:12:39 +0100, Sean Kelly wrote: > >> On Apr 23, 2013, at 2:21 PM, Jack Applegame wrote: >>> >>> According WinAPI documentation, CtrlHandler will be called in new >>> additional thre

Re: WinAPI callbacks and GC

2013-04-30 Thread Sean Kelly
On Apr 23, 2013, at 2:21 PM, Jack Applegame wrote: > > According WinAPI documentation, CtrlHandler will be called in new additional > thread. Is it safe to allocate GC memory in NOT Phobos threads? > If not, how to make it safe? I'm trying call thread_attachThis() at the > beginning of CtrlHand

Re: Exiting blocked threads (socket.accept)

2013-03-27 Thread Sean Kelly
Have each thread select() on the read end of a pipe that the main thread writes to when it wants to trigger a wakeup--write() is legal even in signal handlers.

Re: When to call setAssertHandler?

2013-03-27 Thread Sean Kelly
On Mar 26, 2013, at 11:37 AM, Benjamin Thaut wrote: > Am 25.03.2013 23:49, schrieb Sean Kelly: >> On Mar 22, 2013, at 2:58 AM, Benjamin Thaut wrote: >> >>> So I want to install my own assertHandler. The problem is, that even if I >>> call "setAssetHandle

Re: When to call setAssertHandler?

2013-03-25 Thread Sean Kelly
On Mar 22, 2013, at 2:58 AM, Benjamin Thaut wrote: > So I want to install my own assertHandler. The problem is, that even if I > call "setAssetHandler" in a shared module constructor, and that module does > not import any other modules, it is still not initialized first. Is there a > way to se

Re: Can std.json handle Unicode?

2013-03-25 Thread Sean Kelly
On Mar 23, 2013, at 5:22 AM, Jacob Carlborg wrote: > I'm wondering because I see that std.json uses isControl, isDigit and > isHexDigit from std.ascii and not std.uni. This also causes a problem with a > pull request I recently made for std.net.isemail. In one of its unit tests > the DEL chara

Re: Concurrency and program speed

2013-02-28 Thread Sean Kelly
Does the laptop really have 4 cores or is it 2 cores with hyperthreading? My guess is the latter, and that will contribute to the timing you're seeing. Also, other things are going on in the system. Do larger jobs show a better or worse speedup? On Feb 28, 2013, at 6:15 AM, Joseph Rushton Wake

Re: GC free Writer

2013-02-08 Thread Sean Kelly
On Feb 8, 2013, at 7:57 AM, David wrote: > I am currently implementing a logging module, I want to make logging to > stderr/stdout/"any file" possible, also during runtime-shutdown (logging > from dtors) > > Atm it lookes like this: > > > void log(LogLevel level, Args...)(Args args) { >

Re: Understanding the GC

2013-02-01 Thread Sean Kelly
On Jan 31, 2013, at 11:07 PM, "monarch_dodra" wrote: > On Thursday, 31 January 2013 at 23:53:26 UTC, Steven Schveighoffer wrote: >> >> A destructor should ONLY be used to free up resources other than GC >> allocated memory. Because of that, it's generally not used. >> >> It should be used a

  1   2   >