Is this project possible?

Benji Smith dlanguage at benjismith.net
Tue Aug 5 12:44:00 PDT 2008


Robert Fraser wrote:
>> Ideally, I'd like to write this client library in D, but there seem to 
>> be some blocking issues. For example, I've read that the garbage 
>> collectors for D and Java conflict with one another (in that they listen 
>> for the same OS signals) and that any native JNI code developed with D 
>> needs to avoid using the garbage collector.
> 
> Only in Linux. This, of course, can be worked around using IPC, but it's a bit of a hassle & takes more system resources.

That's great news! Since Windows will be my dominant platform, that 
makes me feel much better. But since I want to also build on Linux & 
OSX, I'll have to be careful. Though I'm glad to hear that the problem 
scenario is isolated to Java/Linux. I think I can work around that...

I don't think IPC is an option though, because I want my library to run 
in the same process as the host application (just within its own 
thread). When an application developer embeds the library in another 
product, it will make HTTP requests, and if a firewall reports those 
requests to the user, I think it'd look fishy if the requests come from 
a separate process.

>> But is it possible to create 
>> Threads and HTTP connections without using the GC? (Inidentally, I'd 
>> planned on using Tango with D 1.x, if that makes any difference.)
> 
> Yes... as long as you're not doing too much allocation & never need to collect, you don't need a GC. Tango is a lot better than Phobos at this (look at Mango; it does very little allocation [= none] once the server has been set up.

Cool. I'll take a look to the Mango project for inspiration. It's 
possible that the Thread will be long-lived, since some desktop 
applications run for days or weeks without restarting, and my library 
will make occasional status reports to the server throughout the 
lifetime of the application. So, I'll have to come up with clever 
strategies for avoiding allocation.

>> Does the same conflict exist with the .Net GC? Does it make any 
>> difference if I plan on using the Tango GC rather than the one in Phobos?
> 
> Not the .NET Windows one, since the problem is only on Linux. Not sure about Mono.

Thanks for the quick reply, and for all the helpful info!

Also: In the process of building my product, I'll probably develop a few 
handy bits of code for auto-generating wrappers (e.g., JNI, .NET, etc) 
from a D codebase. If other people are interested in those kinds of 
wrappers, I'd be happy to share them with the community.

--benji



More information about the Digitalmars-d mailing list