Photon v0.12.1 with 50% faster eventloop

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Aug 13 13:28:26 UTC 2025


On Wednesday, 13 August 2025 at 10:08:17 UTC, Dmitry Olshansky 
wrote:
> On Wednesday, 13 August 2025 at 09:46:07 UTC, GL wrote:
>> On Tuesday, 12 August 2025 at 14:14:04 UTC, Dmitry Olshansky 
>> wrote:
>>> That would be something I could look into. I think it should 
>>> be easily fixable. Do you have some examples that fail?
>>
>> Hello!
>> Shure:
>>
>> import zmqd;
>>
>>    zmqd.Context context;
>>    zmqd.Socket rec;
>>
>>    context = Context();
>>    rec = Socket(context, SocketType.pull);
>>
>> ----------
>>
>> Invalid argument (src/poll.cpp:159)
>> Error Program exited with code -6

So that was trivial mistake in handling -1 argument to poll.

Some more digging around and I've got the following to work:

import std.stdio;
import zmqd;
import photon;
import core.thread;

void main()
{
	startloop();
	shared bool terminated = false;
	go({
     	//  Socket to talk to clients
		auto responder = Socket(SocketType.rep);
		writeln("Got socket");
		responder.bind("tcp://*:5555");
		writeln("Binded socket");

		while (!terminated) {
			ubyte[10] buffer;
			responder.receive(buffer);
			writefln("Received: \"%s\"", cast(string)buffer);
			Thread.sleep(1.seconds);
			responder.send("World");
		}
	});
	go({
		writeln ("Connecting to hello world server...");
		auto requester = Socket(SocketType.req);
		requester.connect("tcp://localhost:5555");

		foreach (int requestNbr; 0..10)
		{
			ubyte[10] buffer;
			writefln("Sending Hello #%s", requestNbr);
			if (requestNbr == 9) terminated = true;
			requester.send("Hello");
			requester.receive(buffer);
			writefln("Received: %s #%s", cast(string)buffer, requestNbr);
		}
	});
	runFibers();
}

I need to think a little more about it but I would likely ship it 
in the next release. Soonish :)




More information about the Digitalmars-d-announce mailing list