Throwable catching

Alexandr Druzhinin drug2004 at bk.ru
Sat Sep 28 01:42:43 PDT 2013


catching Throwable is wrong. But is it wrong if I used it in separate 
thread to prevent thread dying like:

static void run()
{
	while(true)
	{
		try
		{
			/// do work
			...

			// interacting with parent
			auto msg = receiveTimeout(dur!"msecs"(1),
				(string command)
				{
					/// process command from parent
					if(some_condition_is_true)
						break; // finish
						       // execution
				}
			);
		}
		catch(Throwable t)
		{
			/// some diagnostic message
		}
	}
}

...

auto child = spawn(&run);

...

?


More information about the Digitalmars-d-learn mailing list