package reuse.pipe.decorator;

import reuse.pipe.Decorator;
import reuse.pipe.Target;

public class DelayDecorator<T> extends Decorator<T> {
	static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(DelayDecorator.class);

	private int nanos = 1000*1000; // 1ms

	public DelayDecorator(int nanos, Target<T> target) {
		super(target);
		this.nanos = nanos;
	}

	public DelayDecorator(Target<T> target) {
		super(target);
	}

	@Override
	public void send(T o) {
		try {
			Thread.sleep(0, nanos);
		} catch (InterruptedException e) {
			log.warn("", e);
		} finally {
			super.send(o);
		}
	}
}

@@ -244,37 +244,49 @@
 ate 
-int nanos = 1000*1000; // 1ms
+long millis = 1;%0D%0A%09private int nanos = 0;
 %0D%0A%0D%0A
@@ -346,44 +346,30 @@
 %0D%0A%09%09
-super(target);%0D%0A%09%09this.nanos = nanos
+this(0, nanos, target)
 ;%0D%0A%09
@@ -396,16 +396,40 @@
 corator(
+long millis, int nanos, 
 Target%3CT
@@ -455,24 +455,111 @@
 r(target);%0D%0A
+%09%09this.millis = millis;%0D%0A%09%09millis += nanos / 1000000;%0D%0A%09%09this.nanos = nanos %25 100000;%0D%0A
 %09%7D%0D%0A%0D%0A%09@Over
@@ -615,17 +615,22 @@
 d.sleep(
-0
+millis
 , nanos)

fix error where Thread.sleep doesn't accept large values in nanos param