[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Assembly: Db4objects.Db4o (in Db4objects.Db4o.dll)
, if the semaphore could be set or if the
calling transaction already owned the semaphore.
, if the semaphore is owned by another
transaction.
attempts to set a semaphore.
Namespace: Db4objects.Db4o.Ext
Assembly: Db4objects.Db4o (in Db4objects.Db4o.dll)
Syntax
Visual Basic (Declaration) |
---|
Function SetSemaphore ( _ name As String, _ waitForAvailability As Integer _ ) As Boolean |
C# |
---|
bool SetSemaphore ( string name, int waitForAvailability ) |
Visual C++ |
---|
bool SetSemaphore ( String^ name, int waitForAvailability ) |
Parameters
- name
- System.String
the name of the semaphore to be set
- waitForAvailability
- System.Int32
the time in milliseconds to wait for other transactions to release the semaphore. The parameter may be zero, if the method is to return immediately.
Return Value
boolean flag![]() | |
---|---|
true |
![]() | |
---|---|
false |
Remarks
attempts to set a semaphore.
Semaphores are transient multi-purpose named flags for ObjectContainers .
A transaction that successfully sets a semaphore becomes the owner of the semaphore. Semaphores can only be owned by a single transaction at one point in time.
This method returns true, if the transaction already owned the semaphore before the method call or if it successfully acquires ownership of the semaphore.
The waitForAvailability parameter allows to specify a time in milliseconds to wait for other transactions to release the semaphore, in case the semaphore is already owned by another transaction.
Semaphores are released by the first occurence of one of the following:
- the transaction releases the semaphore with Db4objects.Db4o.Ext.IExtObjectContainer.ReleaseSemaphore
- the transaction is closed with Db4objects.Db4o.IObjectContainer.Close
- C/S only: the corresponding Db4objects.Db4o.IObjectServer is closed.
- C/S only: the client Db4objects.Db4o.IObjectContainer looses the connection and is timed out.
Semaphores are set immediately. They are independant of calling Db4objects.Db4o.IObjectContainer.Commit or Db4objects.Db4o.IObjectContainer.Rollback .
Possible usecases for semaphores:
- prevent other clients from inserting a singleton at the same time. A suggested name for the semaphore: "SINGLETON_" + Object#getClass().getName().
- lock objects. A suggested name: "LOCK_" + getID(Object)
- generate a unique client ID. A suggested name: "CLIENT_" + System.currentTimeMillis().
Semaphores are transient multi-purpose named flags for ObjectContainers .
A transaction that successfully sets a semaphore becomes the owner of the semaphore. Semaphores can only be owned by a single transaction at one point in time.
This method returns true, if the transaction already owned the semaphore before the method call or if it successfully acquires ownership of the semaphore.
The waitForAvailability parameter allows to specify a time in milliseconds to wait for other transactions to release the semaphore, in case the semaphore is already owned by another transaction.
Semaphores are released by the first occurence of one of the following:
- the transaction releases the semaphore with Db4objects.Db4o.Ext.IExtObjectContainer.ReleaseSemaphore
- the transaction is closed with Db4objects.Db4o.IObjectContainer.Close
- C/S only: the corresponding Db4objects.Db4o.IObjectServer is closed.
- C/S only: the client Db4objects.Db4o.IObjectContainer looses the connection and is timed out.
Semaphores are set immediately. They are independant of calling Db4objects.Db4o.IObjectContainer.Commit or Db4objects.Db4o.IObjectContainer.Rollback .
Possible usecases for semaphores:
- prevent other clients from inserting a singleton at the same time. A suggested name for the semaphore: "SINGLETON_" + Object#getClass().getName().
- lock objects. A suggested name: "LOCK_" + getID(Object)
- generate a unique client ID. A suggested name: "CLIENT_" + System.currentTimeMillis().