Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio;
- import std.concurrency;
- class CustomMsg
- {
- private:
- immutable this()
- {
- }
- public:
- static immutable(CustomMsg) create()
- {
- auto msg = new immutable(CustomMsg)();
- return msg;
- }
- }
- void main()
- {
- auto testThread = spawn({
- bool terminated = false;
- while (!terminated)
- {
- try
- {
- receive
- (
- (immutable(CustomMsg) msg) { writeln("Received custom message"); },
- (OwnerTerminated ot) { writeln("Terminated"); terminated = true; }
- );
- }
- catch(Throwable t)
- {
- writeln(t.toString());
- }
- }
- });
- auto msg = CustomMsg.create();
- testThread.send(msg);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement