Removing array element in foreach, safe?

dom via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 5 08:53:39 PDT 2016


is this code safe? if not how do i do it correctly?

         static AsyncHttpGet[] openRequests;
	static void updateRequests()
	{
		foreach(idx, req; openRequests)
		{
			if(req.state != Fiber.State.TERM)
				req.call();
			else
				openRequests.remove(idx);
		}
	}

thx :)


More information about the Digitalmars-d-learn mailing list