Databases and the D Standard Library

rikki cattermole via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 1 20:26:51 PST 2017


On 02/01/2017 4:44 PM, Adam Wilson wrote:
> rikki cattermole wrote:
>> On 02/01/2017 3:03 PM, Adam Wilson wrote:
>>> rikki cattermole wrote:
>>>> On 01/01/2017 5:19 PM, Adam D. Ruppe wrote:
>>>>> On Sunday, 1 January 2017 at 03:51:52 UTC, rikki cattermole wrote:
>>>>>> Which is fine if all you use is c's sockets or only that database
>>>>>> connection for a thread.
>>>>>
>>>>> The C drivers typically offer handles of some sort (Windows HANDLE,
>>>>> *nix
>>>>> file descriptor, that kind of thing) that you can integrate into other
>>>>> event loops.
>>>>
>>>> That's fine and all, but you've still got to deal with it on D's
>>>> side so
>>>> you can mix and match libraries that require access to the same event
>>>> loop (such as Windows).
>>>
>>> Vibe.d is working on a native D event loop. We would probably want to
>>> integrate with that.
>>>
>>> EventCore: https://code.dlang.org/packages/eventcore
>>>
>>
>> No, it isn't generic enough.
>> Nor can it handle windowing without a good bit of modifications.
>>
>> Mine in SPEW[0] is however ready for this task.
>>
>> [0]
>> https://github.com/Devisualization/spew/tree/master/src/base/cf/spew/event_loop
>>
>>
>
> How much effort to make the changes? Their plans seem to indicate that
> they want to support UI integration. I ask because I need to use the
> library that is going to get the most support over time and that is
> vibe.d right now.

Read and compare the code.
To add anything into the Vibe.d one requires direct modification which 
is unacceptable for Phobos IMO.

My aim for SPEW was to be as close as glib's[0] as reasonably possible. 
A well tested set of features.

I'm sorry but this is just not acceptable[1] for an event loop:

interface EventDriver {
@safe: /*@nogc:*/ nothrow:
	@property EventDriverCore core();
	@property EventDriverTimers timers();
	@property EventDriverEvents events();
	@property EventDriverSignals signals();
	@property EventDriverSockets sockets();
	@property EventDriverDNS dns();
	@property EventDriverFiles files();
	@property EventDriverWatchers watchers();

	/// Releases all resources associated with the driver
	void dispose();
}

Its fine for a web framework, aka a specific task but not when its generic.

When we're discussing a generic event loop it shouldn't care about the 
different usage of it. All it knows is that there are events that come 
from sources and then mapped to a consumer. It isn't the most performant 
but that is ok. You would use a different implementation depending on 
your use case e.g. 1:1 is easy enough to do without a event loop manager.

Just so you're aware, windowing is extremely hard to get right. Sockets, 
DNS, signals and timers ext. are easy to implement compared.

[0] https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html
[1] 
https://github.com/vibe-d/eventcore/blob/master/source/eventcore/driver.d


More information about the Digitalmars-d mailing list