bool ExpandableBlockStreamExchangeEpoll::close()
{
	logging_->log("[%ld] Close: nexhausted lowers=%d, nlower=%d", state.exchange_id_, nexhausted_lowers, nlowers);

	CancelReceiverThread();

	CloseTheSocket();

	/* free the temporary resource/ */
	for (unsigned i = 0; i < nlowers; i++)
	{
		delete block_for_socket_[i];
		;
	}
	delete received_block_stream_;
	delete buffer;
	delete[] block_for_socket_;

	/* rest the status of this iterator instance, such that the following calling of open() and next() can
	 * act correctly.
	 */
	resetStatus();

	Environment::getInstance()->getExchangeTracker()->LogoutExchange(ExchangeID(state.exchange_id_, partition_offset));
	logging_->log("[%ld] ExchangeUpper is closed!", state.exchange_id_);

	return true;
}
bool ExpandableBlockStreamExchangeMaterialized::close(){
	FILE* file;
	void* addr;


	sem_open_.set_value(1);
	block_for_socket_->~BlockReadable();
	received_block_stream_->~BlockStreamBase();
	buffer->~BlockStreamBuffer();


	CloseTheSocket();

	Environment::getInstance()->getExchangeTracker()->LogoutExchange(ExchangeID(state_.exchange_id_,0));

	return true;
}
bool ExpandableBlockStreamExchange::close(){
	CancelReceiverThread();

	for(unsigned i=0;i<nlowers;i++){
		FileClose(this->socket_fd_lower_list[i]);
	}

	block_for_socket_->~BlockReadable();
	received_block_stream_->~BlockStreamBase();
	buffer->~BlockStreamBuffer();

	delete[] socket_fd_lower_list;

	CloseTheSocket();

	Environment::getInstance()->getExchangeTracker()->LogoutExchange(state.exchange_id);

	return true;
}