Exemple #1
0
uint32 RemoteListMessage::ipcOnPrepare(frame::ipc::ConnectionContext const &_rctx){
	Locker<Mutex>						lock(shared_mutex(this));
	
	if(success == 0) success = 1;//wait
	idbg(""<<(void*)this);
	if(ipcIsOnSender()){//on sender
		return frame::ipc::WaitResponseFlag /*| frame::ipc::SynchronousSendFlag*/;
	}else{
		return 0/*frame::ipc::Service::SynchronousSendFlag*/;// on peer
	}
}
Exemple #2
0
void RemoteListMessage::ipcOnComplete(frame::ipc::ConnectionContext const &_rctx, int _err){
	Locker<Mutex> lock(shared_mutex(this));
	err = _err;
	if(!_err){
		success = 2;
	}else{
		if(ipcIsOnSender()){
			idbg("failed on sender "<<(void*)this);
		}else{
			idbg("failed on peer");
		}
	}
}
	virtual void publish(){
		uint8_t i;

		//Before beginning the copy we have to take the mutex, but because
		//we actually copy the WHOLE instance the mutex will be copied as well
		//so we'll loose our handle to the shared structure mutex. Therefore we
		//save it before the copy:
		Mutex shared_mutex(shared->mutex);

		shared_mutex.take();
		for(i=0; i<this->size(); i++){
			((uint8_t*)shared)[i] = ((uint8_t*)this)[i];
		}
		shared_mutex.release();

		//Now the mutex handle in the actual shared structure has been overwritten!
		//Therefore we will just reassign it:
		shared->mutex = shared_mutex;
	}