Documentation updates

This commit is contained in:
WebFreak001 2017-04-23 16:39:28 +02:00
parent 408cda19bc
commit 96605cf2bc
5 changed files with 39 additions and 8 deletions

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ __dummy.html
/ddbus /ddbus
libddbus.* libddbus.*
__test__library__ __test__library__
/ddbus-test-*

View file

@ -18,7 +18,7 @@ Before using, you will need to have the DBus C library installed on your compute
`ddbus` is available on [DUB](http://code.dlang.org/packages/ddbus) so you can simply include it in your `dub.json`: `ddbus` is available on [DUB](http://code.dlang.org/packages/ddbus) so you can simply include it in your `dub.json`:
```json ```json
"dependencies": { "dependencies": {
"ddbus": "~>1.0.0" "ddbus": "~>2.0.0"
} }
``` ```
@ -62,6 +62,9 @@ Setting read only properties results in a thrown `DBusException`.
You can register a delegate into a `MessageRouter` and a main loop in order to handle messages. You can register a delegate into a `MessageRouter` and a main loop in order to handle messages.
After that you can request a name so that other DBus clients can connect to your program. After that you can request a name so that other DBus clients can connect to your program.
You can return a `Tuple!(args)` to return multiple values (multiple out values in XML) or
return a `Variant!DBusAny` to support returning any dynamic value.
```d ```d
import ddbus; import ddbus;
MessageRouter router = new MessageRouter(); MessageRouter router = new MessageRouter();
@ -89,8 +92,7 @@ bool gotem = requestName(conn, "ca.thume.ddbus.test");
simpleMainLoop(conn); simpleMainLoop(conn);
``` ```
Note that `ddbus` currently only supports a simple event loop that is really only suitable for apps that don't do See the Concurrent Updates section for details how to implement this in a custom main loop.
anything except respond to DBus messages. Other threads handling other things concurrently may or may not work with it. See the todo section for notes on potential `vibe.d` compatibility.
## Thin(ish) Wrapper ## Thin(ish) Wrapper
@ -133,11 +135,33 @@ you can import the others if you want lower level control.
Nothing is hidden so if `ddbus` doesn't provide something you can simply import `c_lib` and use the pointers Nothing is hidden so if `ddbus` doesn't provide something you can simply import `c_lib` and use the pointers
contained in the thin wrapper structs to do it yourself. contained in the thin wrapper structs to do it yourself.
# Concurrent Updates
If you want to use the DBus connection concurrently with some other features
or library like a GUI or vibe.d you can do so by placing this code in the update/main loop:
```d
// initialize Connection conn; somewhere
// on update:
if (!conn.tick)
return;
```
Or in vibe.d:
```d
runTask({
import vibe.core.core : yield;
while (conn.tick)
yield(); // Or sleep(1.msecs);
});
```
# Todo # Todo
`ddbus` should be complete for everyday use but is missing some fanciness that it easily could and should have: `ddbus` should be complete for everyday use but is missing some fanciness that it easily could and should have:
- [vibe.d](http://vibed.org/) event loop compatibility so that calls don't block everything and more importantly, it is possible to write apps that have a DBus server and can do other things concurrently, like a GUI.
- Marshaling of DBus path and file descriptor objects - Marshaling of DBus path and file descriptor objects
- Better efficiency in some places, particularly the object wrapping allocates tons of delegates for every method. - Better efficiency in some places, particularly the object wrapping allocates tons of delegates for every method.

View file

@ -1,12 +1,12 @@
{ {
"name": "ddbus", "name": "ddbus",
"description": "A DBus library for D", "description": "A DBus library for D",
"homepage": "http://github.com/trishume/ddbus", "homepage": "https://github.com/trishume/ddbus",
"copyright": "Copyright © 2015, Tristan Hume", "copyright": "Copyright © 2017, Tristan Hume",
"license": "MIT", "license": "MIT",
"authors": ["Tristan Hume"], "authors": ["Tristan Hume"],
"lflags": ["-ldbus-1"], "lflags": ["-ldbus-1"],
"dependencies": { "dependencies": {
"dunit": "~>1.0.10" "dunit": "~>1.0.14"
} }
} }

View file

@ -1,6 +1,6 @@
{ {
"fileVersion": 1, "fileVersion": 1,
"versions": { "versions": {
"dunit": "1.0.10" "dunit": "1.0.14"
} }
} }

View file

@ -31,6 +31,12 @@ void simpleMainLoop(Connection conn) {
while(dbus_connection_read_write_dispatch(conn.conn, -1)) {} // empty loop body while(dbus_connection_read_write_dispatch(conn.conn, -1)) {} // empty loop body
} }
/// Single tick in the DBus connection which can be used for
/// concurrent updates.
bool tick(Connection conn) {
return cast(bool) dbus_connection_read_write_dispatch(conn.conn, 0);
}
unittest { unittest {
import dunit.toolkit; import dunit.toolkit;
Connection conn = connectToBus(); Connection conn = connectToBus();