Top |
double | delay | Read / Write |
double | frequency | Read / Write |
double | max-precision | Read / Write |
#define | AGS_THREAD_HERTZ_JIFFIE |
#define | AGS_THREAD_YIELD_JIFFIE |
#define | AGS_THREAD_DEFAULT_JIFFIE |
#define | AGS_THREAD_DEFAULT_MAX_PRECISION |
#define | AGS_THREAD_MAX_PRECISION |
#define | AGS_THREAD_DEFAULT_ATTACK |
#define | AGS_THREAD_TOLERANCE |
enum | AgsThreadFlags |
enum | AgsThreadStatusFlags |
enum | AgsThreadSyncTicFlags |
GFlags ├── AgsThreadFlags ├── AgsThreadStatusFlags ╰── AgsThreadSyncTicFlags GObject ╰── AgsThread ├── AgsWorkerThread ├── AgsGenericMainLoop ╰── AgsReturnableThread
The AgsThread base class. It supports organizing them within a tree, perform syncing and frequencies.
The thread class synchronizes within tree at max-precision
property
JIFFIE. AgsThread::run()
is called at frequency
property JIFFIE.
The AgsThread::run()
function can sync to the very same tic with
AGS_THREAD_IMMEDIATE_SYNC
flag, sync to the previous or next tic with
AGS_THREAD_INTERMEDIATE_PRE_SYNC
or AGS_THREAD_INTERMEDIATE_POST_SYNC
flag set.
The AgsTread::clock()
function is called at max-precision
property
rate per second.
Note you usually have a default source giving you timing hints i.e.
poll is used. If not you can still set the AGS_THREAD_TIME_ACCOUNTING
flags, causing a sleep for every tic.
Further there is no time promise within one second. But you should make sure you hit the real-time dead-line or use a worker thread instead for time expensive work or tasks.
ags_thread_self() returns you your own AgsThread you are running
in or NULL
if not applicable.
To create a new thread, connect AgsThread::run()
and attach it to
main loop use the following example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
AgsThread *main_loop; AgsThread *thread; AgsApplicationContext *application_context; gdouble frequency; ags_thread_application_context_new(); application_context = ags_application_context_get_instance(); main_loop = ags_concurrency_provider_get_main_loop(AGS_CONCURRENCY_PROVIDER(application_context)); frequency = 0.004; // frequency equals to 0.004 causes AgsThread::run() to be emitted 250 times per second. thread = ags_thread_new(); ags_thread_set_frequency(thread, frequency); g_signal_connect(thread, "run", G_CALLBACK(my_app_run_callback), my_data); ags_thread_add_start_queue(main_loop, thread); |
#define AGS_THREAD_GET_OBJ_MUTEX(obj) (&(((AgsThread *) obj)->obj_mutex))
#define AGS_THREAD_GET_WAIT_MUTEX(obj) (&(((AgsThread *) obj)->wait_mutex))
#define AGS_THREAD_GET_WAIT_COND(obj) (&(((AgsThread *) obj)->wait_cond))
#define AGS_THREAD_GET_TIC_MUTEX(obj) (&(((AgsThread *) obj)->tic_mutex))
#define AGS_THREAD_GET_START_MUTEX(obj) (&(((AgsThread *) obj)->start_mutex))
#define AGS_THREAD_GET_START_COND(obj) (&(((AgsThread *) obj)->start_cond))
gboolean
ags_thread_global_get_use_sync_counter
();
Get global config value use sync counter.
Since: 3.0.0
gboolean ags_thread_test_flags (AgsThread *thread
,AgsThreadFlags flags
);
Test flags
to be set on thread
.
Since: 3.0.0
void ags_thread_set_flags (AgsThread *thread
,AgsThreadFlags flags
);
Set flags.
Since: 3.0.0
void ags_thread_unset_flags (AgsThread *thread
,AgsThreadFlags flags
);
Unset flags.
Since: 3.0.0
gboolean ags_thread_test_status_flags (AgsThread *thread
,AgsThreadStatusFlags status_flags
);
Test status_flags
to be set on thread
.
Since: 3.0.0
void ags_thread_set_status_flags (AgsThread *thread
,AgsThreadStatusFlags status_flags
);
Set status flags.
Since: 3.0.0
void ags_thread_unset_status_flags (AgsThread *thread
,AgsThreadStatusFlags status_flags
);
Unset status flags.
Since: 3.0.0
void
ags_thread_clear_status_flags (AgsThread *thread
);
Clear status flags.
Since: 3.0.0
gboolean ags_thread_test_sync_tic_flags (AgsThread *thread
,AgsThreadSyncTicFlags sync_tic_flags
);
Test sync_tic_flags
to be set on thread
.
Since: 3.0.0
void ags_thread_set_sync_tic_flags (AgsThread *thread
,AgsThreadSyncTicFlags sync_tic_flags
);
Set sync-tic flags.
Since: 3.0.0
void ags_thread_unset_sync_tic_flags (AgsThread *thread
,AgsThreadSyncTicFlags sync_tic_flags
);
Unset sync-tic flags.
Since: 3.0.0
void
ags_thread_clear_sync_tic_flags (AgsThread *thread
);
Clear sync-tic flags.
Since: 3.0.0
void ags_thread_set_current_sync_tic (AgsThread *thread
,guint current_sync_tic
);
Set current sync-tic.
Since: 3.0.0
guint
ags_thread_get_current_sync_tic (AgsThread *thread
);
Get current sync-tic.
Since: 3.0.0
void ags_thread_set_delay (AgsThread *thread
,gdouble delay
);
Set delay.
Since: 3.0.0
void ags_thread_set_frequency (AgsThread *thread
,gdouble frequency
);
Set frequency.
Since: 3.0.0
gdouble
ags_thread_get_frequency (AgsThread *thread
);
Get frequency.
Since: 3.0.0
void ags_thread_set_max_precision (AgsThread *thread
,gdouble max_precision
);
Set max-precision.
Since: 3.0.0
gdouble
ags_thread_get_max_precision (AgsThread *thread
);
Get max-precision.
Since: 3.0.0
AgsThread * ags_thread_find_type (AgsThread *thread
,GType gtype
);
Find gtype
as descendant of thread
. If its a descendant thread,
the ref-count is increased.
Since: 3.0.0
AgsThread *
ags_thread_parent (AgsThread *thread
);
Get parent thread.
Since: 3.0.0
AgsThread *
ags_thread_children (AgsThread *thread
);
Get children thread.
Since: 3.0.0
AgsThread *
ags_thread_get_toplevel (AgsThread *thread
);
Retrieve toplevel thread.
Since: 3.0.0
AgsThread *
ags_thread_first (AgsThread *thread
);
Retrieve first sibling.
Since: 3.0.0
AgsThread *
ags_thread_last (AgsThread *thread
);
Retrieve last sibling.
Since: 3.0.0
void
ags_thread_lock (AgsThread *thread
);
Locks the threads own mutex and sets the appropriate flag.
Since: 3.0.0
gboolean
ags_thread_trylock (AgsThread *thread
);
Locks the threads own mutex if available and sets the
appropriate flag and returning TRUE
. Otherwise return FALSE
without lock.
Since: 3.0.0
void
ags_thread_unlock (AgsThread *thread
);
Unlocks the threads own mutex and unsets the appropriate flag.
Since: 3.0.0
void ags_thread_remove_child (AgsThread *thread
,AgsThread *child
);
Remove child of thread.
Since: 3.0.0
void ags_thread_add_child (AgsThread *thread
,AgsThread *child
);
Add child to thread.
Since: 3.0.0
void ags_thread_add_child_extended (AgsThread *thread
,AgsThread *child
,gboolean no_start
,gboolean no_wait
);
Add child to thread.
thread |
the AgsThread |
|
child |
the child to remove |
|
no_start |
don't start thread |
|
no_wait |
don't wait until started |
Since: 3.0.0
gboolean ags_thread_is_current_ready (AgsThread *current
,guint current_sync_tic
);
gboolean ags_thread_is_tree_ready_recursive (AgsThread *thread
,guint current_sync_tic
);
void ags_thread_prepare_current_sync (AgsThread *current
,guint current_sync_tic
);
void ags_thread_prepare_tree_sync_recursive (AgsThread *thread
,guint current_sync_tic
);
void ags_thread_set_current_sync (AgsThread *current
,guint current_sync_tic
);
void ags_thread_set_tree_sync_recursive (AgsThread *thread
,guint current_sync_tic
);
void ags_thread_add_start_queue (AgsThread *thread
,AgsThread *child
);
Add child
to thread
's start queue.
Since: 3.0.0
void ags_thread_add_start_queue_all (AgsThread *thread
,GList *child
);
Add child
to thread
's start queue.
Since: 3.0.0
void
ags_thread_run (AgsThread *thread
);
Only for internal use of ags_thread_loop but you may want to set the your very own class function namely your thread's routine.
Since: 3.0.0
void
ags_thread_stop (AgsThread *thread
);
Stop the threads loop by unsetting AGS_THREAD_STATUS_RUNNING flag.
Since: 3.0.0
Enum values to control the behavior or indicate internal state of AgsThread by enable/disable as flags.
Enum values to control the behavior or indicate internal state of AgsThread by enable/disable as status flags.
realtime setup was performed |
||
initial sync indicates the thread wasn't synced before |
||
the first call to |
||
the thread is not synced |
||
the thread start is waiting |
||
the thread start is done |
||
the thread is ready |
||
the thread is waiting |
||
the thread is running |
||
the thread is locked |
||
the thread is busy |
||
the thread joined the tic based system, it is synced |
||
the frequency was synced |
Enum values to control the behavior or indicate internal state of AgsThread by enable/disable as sync tic flags.
wait tree to be synced |
||
done tree to be synced |
||
wait tree to be synced |
||
done tree to be synced |
||
wait tree to be synced |
||
done tree to be synced |
||
wait tree to be synced |
||
done tree to be synced |
||
wait tree to be synced |
||
done tree to be synced |
||
wait tree to be synced |
||
done tree to be synced |
||
wait tree to be synced |
||
done tree to be synced |
||
wait tree to be synced |
||
done tree to be synced |
||
wait tree to be synced |
||
done tree to be synced |
“delay”
property “delay” double
The delay until next tic.
Owner: AgsThread
Flags: Read / Write
Allowed values: [1,1000]
Default value: 1
Since: 3.0.0
“frequency”
property “frequency” double
The frequency to run at in Hz.
Owner: AgsThread
Flags: Read / Write
Allowed values: [0.01,1000]
Default value: 250
Since: 3.0.0
“clock”
signalguint user_function (AgsThread *thread, gpointer user_data)
The ::clock()
signal is invoked every thread tic.
Flags: Run Last
Since: 3.0.0
“run”
signalvoid user_function (AgsThread *thread, gpointer user_data)
The ::run()
signal is invoked during run loop.
Flags: Run Last
Since: 3.0.0
“start”
signalvoid user_function (AgsThread *thread, gpointer user_data)
The ::start()
signal is invoked as thread started.
Flags: Run Last
Since: 3.0.0