![]() |
fpmas 1.6
|
#include <client_server.h>
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 |
![]() | |
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) |
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.
|
inlineprotected |
Internally locks the mutex.
mutex | to lock |
|
inlineprotected |
Internally unlocks the mutex.
mutex | to unlock |
|
inlineprotected |
Internally share locks the mutex.
mutex | to share lock |
|
inlineprotected |
Internally share unlocks the mutex.
mutex | to share unlock |
|
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.
id | id of the node associated to mutex |
mutex | mutex to manage |
Implemented in fpmas::synchro::hard::MutexServer< T >.
|
pure virtual |
Removes the mutex associated to the specified id from the set of managed mutexes.
id | id of the node associated to the mutex to remove |
Implemented in fpmas::synchro::hard::MutexServer< T >.
|
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.
request | request to wait for |
Implemented in fpmas::synchro::hard::MutexServer< T >.
|
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.
id | id of the node associated to the released mutex |
Implemented in fpmas::synchro::hard::MutexServer< T >.