sociomantic-tsunami / dhtproto

Distributed Hash Table protocol definition, client, fake node, and tests
Boost Software License 1.0
5 stars 22 forks source link

Partial handshake support: Add Task-blocking `RetryHandshake` #126

Closed gavin-norman-sociomantic closed 6 years ago

gavin-norman-sociomantic commented 6 years ago

Either a new implementation or a derived class.

Some applications already have code for this, so it's probably just a case of surveying what we already have, checking it's generic enough for a library, and bringing it in.

gavin-norman-sociomantic commented 6 years ago

Some apps are already adapted to use the existing RetryHandshake in a task-blocking manner. Code like the following indicates that this is simple:

    override public void waitForFullHandshake ( )
    {
        auto task = Task.getThis();
        assert(task !is null);

        bool done;
        new RetryHandshake(theScheduler.epoll, this.dht, RETRY_WAIT, {
            done = true;
            if ( task.suspended ) task.resume;
        });

        if ( !done ) task.suspend();
    }

Given the simple usage of RetryHandshake with tasks and the fact that the exact behaviour required for partial handshakes varies greatly by application, I'm not sure it's worth adding anything more to dhtproto.