public void produce(final ConsumerRecords<byte[], byte[]> element)
			throws InterruptedException, WakeupException, ClosedException {

		checkNotNull(element);

		synchronized (lock) {
			while (next != null && !wakeupProducer) {
				lock.wait();
			}

			wakeupProducer = false;

			// if there is still an element, we must have been woken up
			if (next != null) {
				throw new WakeupException();
			}
			// if there is no error, then this is open and can accept this element
			else if (error == null) {
				next = element;
				lock.notifyAll();
			}
			// an error marks this as closed for the producer
			else {
				throw new ClosedException();
			}
		}
	}
public void produce ( final ConsumerRecords < byte [ ] , byte [ ] > element ) throws InterruptedException , WakeupException , ClosedException { checkNotNull ( element ) ; synchronized ( lock ) { while ( next != null && ! wakeupProducer ) { lock . wait ( ) ; } wakeupProducer = false ; if ( next != null ) { throw new WakeupException ( ) ; } else if ( error == null ) { next = element ; lock . notifyAll ( ) ; } else { throw new ClosedException ( ) ; } } }
Hands over an element from the producer. If the Handover already has an element that was
not yet picked up by the consumer thread, this call blocks until the consumer picks up that
previous element.

<p>This behavior is similar to a "size one" blocking queue.

@param element The next element to hand over.

@throws InterruptedException
Thrown, if the thread is interrupted while blocking for the Handover to be empty.
@throws WakeupException
Thrown, if the {@link #wakeupProducer()} method is called while blocking for
the Handover to be empty.
@throws ClosedException
Thrown if the Handover was closed or concurrently being closed.