Semaphore
Object Hierarchy:
Description:
public class Semaphore :
TaskQueue
A high-level non-recursive counting semaphore
This is a semaphore designed for asynchronous GObject programming. It integrates well with the main event loop and provides features such
as prioritization, cancellation, and asynchronous interfaces. Requests with higher priorities will always be executed first, and requests
of equal priorities will be executed in the order in which they are requested.
Unfortunately, this is relatively slow compared to lower level mutex implementations such as GMutex and pthreads. If you don't require
the advanced features, or if you only need short-lived locks, it would probably be much better to use GMutex. However, if you are writing
an asynchronous GObject-based application the convenience provided by these methods can go a long way towards helping you write
applications don't block the main loop and, therefore, feel faster.
Namespace: Bump
Package: bump-0.1
Content:
Properties:
- public
int
max_claims { construct set; get; }
The maximum number of claims allowed
- public
int
claims { set; get; }
The current number of claims
- public TaskQueue pool { construct set; get; }
Pool used to process requests
Creation methods:
Methods:
- public void unlock ()
Release an anonymous claim
- public override
bool
process (TimeSpan
wait = 0)
- protected override
int
spawn (int
max = -1)
- public override void add (owned
SourceFunc
task, int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
- public void lock (
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Synchronously acquire an anonymous claim
- public async void lock_async (
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Asynchronously acquire an anonymous claim
- public virtual SemaphoreClaim claim (
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Synchronously acquire a claim
- public virtual async SemaphoreClaim claim_async (
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Asynchronously acquire a claim