db4o Semaphores are named flags that can only be owned by one client/transaction at one time. They are supplied to be used as locks for exclusive access to code blocks in applications and to signal states from one client to the server and to all other clients.
The naming of semaphores is up to the application. Any string can be used.
Semaphores are freed automatically when a client disconnects correctly or when a clients presence is no longer detected by the server, that constantly monitors all client connections.
Semaphores can be set and released with the following two methods:
.NET:
IExtObjectContainer#SetSemaphore(string name, int waitMilliSeconds);
IExtObjectContainer#ReleaseSemaphore(string name);
.NET:
lock(monitorObject){
// exclusive code block here
}
.NET:
if(objectContainer.Ext().SetSemaphore(semaphoreName, 1000){
// exclusive code block here
objectContainer.Ext().ReleaseSemaphore(semaphoreName);
}
Although the principle of semaphores is very simple they are powerful enough for a wide range of usecases.