fpmas 1.6
Public Member Functions | Protected Member Functions | List of all members
fpmas::synchro::hard::api::MutexServer< T > Class Template Referenceabstract

#include <client_server.h>

Inheritance diagram for fpmas::synchro::hard::api::MutexServer< T >:
Inheritance graph
[legend]
Collaboration diagram for fpmas::synchro::hard::api::MutexServer< T >:
Collaboration graph
[legend]

Public Member Functions

virtual void manage (DistributedId id, HardSyncMutex< T > *mutex)=0
 
virtual void remove (DistributedId id)=0
 
virtual void wait (const MutexRequest &request)=0
 
virtual void notify (DistributedId id)=0
 
- Public Member Functions inherited from fpmas::synchro::hard::api::Server
virtual void setEpoch (Epoch epoch)=0
 
virtual Epoch getEpoch () const =0
 
virtual void handleIncomingRequests ()=0
 

Protected Member Functions

void lock (HardSyncMutex< T > *mutex)
 
void lockShared (HardSyncMutex< T > *mutex)
 
void unlock (HardSyncMutex< T > *mutex)
 
void unlockShared (HardSyncMutex< T > *mutex)
 

Detailed Description

template<typename T>
class fpmas::synchro::hard::api::MutexServer< T >

MutexServer API.

The purpose of the MutexServer is to respond to requests incoming from other processes.

More precisely, the MutexServer responds to requests if the requested HardSyncMutex is available, or else enqueue the request. Moreover, it is the role of the MutexServer to unqueue pending requests when the HardSyncMutex becomes available again.

Currently, the MutexServer is assumed to run directly in the main thread, assuming a single-threaded environment. In consequence, request are handled only when the MutexClient is performing some requests, to avoid deadlock, and during the termination process of the TerminationAlgorithm.

Member Function Documentation

◆ lock()

template<typename T >
void fpmas::synchro::hard::api::MutexServer< T >::lock ( HardSyncMutex< T > *  mutex)
inlineprotected

Internally locks the mutex.

Parameters
mutexto lock

◆ lockShared()

template<typename T >
void fpmas::synchro::hard::api::MutexServer< T >::lockShared ( HardSyncMutex< T > *  mutex)
inlineprotected

Internally unlocks the mutex.

Parameters
mutexto unlock

◆ unlock()

template<typename T >
void fpmas::synchro::hard::api::MutexServer< T >::unlock ( HardSyncMutex< T > *  mutex)
inlineprotected

Internally share locks the mutex.

Parameters
mutexto share lock

◆ unlockShared()

template<typename T >
void fpmas::synchro::hard::api::MutexServer< T >::unlockShared ( HardSyncMutex< T > *  mutex)
inlineprotected

Internally share unlocks the mutex.

Parameters
mutexto share unlock

◆ manage()

template<typename T >
virtual void fpmas::synchro::hard::api::MutexServer< T >::manage ( DistributedId  id,
HardSyncMutex< T > *  mutex 
)
pure virtual

Adds the provided mutex, associated to the resource id, to the current set of managed mutexes.

A mutex is "managed" means that the MutexServer instance is able to receive and handle requests involving this mutex.

Parameters
idid of the node associated to mutex
mutexmutex to manage

Implemented in fpmas::synchro::hard::MutexServer< T >.

◆ remove()

template<typename T >
virtual void fpmas::synchro::hard::api::MutexServer< T >::remove ( DistributedId  id)
pure virtual

Removes the mutex associated to the specified id from the set of managed mutexes.

Parameters
idid of the node associated to the mutex to remove

Implemented in fpmas::synchro::hard::MutexServer< T >.

◆ wait()

template<typename T >
virtual void fpmas::synchro::hard::api::MutexServer< T >::wait ( const MutexRequest request)
pure virtual

Waits for the specified request to be handled.

This is notably used in a single-threaded environment from the main thread, where the argument request is a request performed by the local process. Indeed, the local process cannot directly access its own resources, since they might be acquired by other processes. To solve this issue, the HardSyncMutex adds a "LOCAL" request to its waiting queue, and "waits" for this request to be handled by the MutexServer to get back to its main execution thread. While "waiting", the MutexServer keeps handling and unqueueing pending requests until the specified request is reached.

Parameters
requestrequest to wait for

Implemented in fpmas::synchro::hard::MutexServer< T >.

◆ notify()

template<typename T >
virtual void fpmas::synchro::hard::api::MutexServer< T >::notify ( DistributedId  id)
pure virtual

Notifies the MutexServer that the local process has released the local mutex associated to the provided id.

This is used to trigger pending requests handling.

Parameters
idid of the node associated to the released mutex

Implemented in fpmas::synchro::hard::MutexServer< T >.


The documentation for this class was generated from the following file: