Advanced Gtk+ Sequencer Reference Manual | ||||
---|---|---|---|---|
Top | Description |
#include <ags/thread/ags_thread.h> #define AGS_ACCOUNTING_TABLE (ptr) #define AGS_THREAD_DEFAULT_ATTACK #define AGS_THREAD_DEFAULT_JIFFIE #define AGS_THREAD_MAX_PRECISION #define AGS_THREAD_RESUME_SIG #define AGS_THREAD_SUSPEND_SIG struct AgsAccountingTable; struct AgsThread; struct AgsThreadClass; enum AgsThreadFlags; #define MSEC_PER_SEC #define NSEC_PER_SEC AgsAccountingTable * ags_accounting_table_alloc (AgsThread *thread
);void ags_accounting_table_set_sanity (,
GList *tableAgsThread *thread
,);
gdouble sanityvoid ags_thread_add_child (AgsThread *thread
,AgsThread *child
);gboolean ags_thread_children_is_locked (AgsThread *thread
); AgsThread * ags_thread_first (AgsThread *thread
); AgsThread * ags_thread_get_toplevel (AgsThread *thread
);void ags_thread_hangcheck (AgsThread *thread
);gboolean ags_thread_is_current_ready (AgsThread *current
,);
guint ticgboolean ags_thread_is_tree_ready (AgsThread *thread
,); AgsThread * ags_thread_last (
guint ticAgsThread *thread
);void ags_thread_lock (AgsThread *thread
);void ags_thread_lock_all (AgsThread *thread
);void ags_thread_lock_children (AgsThread *thread
);void ags_thread_lock_parent (AgsThread *thread
,AgsThread *parent
);void ags_thread_lock_sibling (AgsThread *thread
); AgsThread * ags_thread_new (); AgsThread * ags_thread_next_children_locked (
gpointer dataAgsThread *thread
); AgsThread * ags_thread_next_parent_locked (AgsThread *thread
,AgsThread *parent
); AgsThread * ags_thread_next_sibling_locked (AgsThread *thread
);gboolean ags_thread_parental_is_locked (AgsThread *thread
,AgsThread *parent
);void ags_thread_remove_child (AgsThread *thread
,AgsThread *child
);void ags_thread_resume (AgsThread *thread
);void ags_thread_run (AgsThread *thread
);void ags_thread_set_sync (AgsThread *thread
,);
guint ticvoid ags_thread_set_sync_all (AgsThread *thread
,);
guint ticgboolean ags_thread_sibling_is_locked (AgsThread *thread
);void ags_thread_signal_children (AgsThread *thread
,);
gboolean broadcastvoid ags_thread_signal_parent (AgsThread *thread
,AgsThread *parent
,);
gboolean broadcastvoid ags_thread_signal_sibling (AgsThread *thread
,);
gboolean broadcastvoid ags_thread_start (AgsThread *thread
);void ags_thread_stop (AgsThread *thread
);void ags_thread_suspend (AgsThread *thread
);void ags_thread_timelock (AgsThread *thread
);gboolean ags_thread_trylock (AgsThread *thread
);void ags_thread_unlock (AgsThread *thread
);void ags_thread_unlock_all (AgsThread *thread
);void ags_thread_unlock_children (AgsThread *thread
);void ags_thread_unlock_parent (AgsThread *thread
,AgsThread *parent
);void ags_thread_unlock_sibling (AgsThread *thread
);void ags_thread_wait_children (AgsThread *thread
);void ags_thread_wait_parent (AgsThread *thread
,AgsThread *parent
);void ags_thread_wait_sibling (AgsThread *thread
);
The AgsThread base class. It supports organizing them within a tree, perform syncing and frequencies.
struct AgsThread { GObject object; volatile guint flags; sigset_t wait_mask; pthread_t thread; pthread_attr_t thread_attr; gdouble freq; pthread_mutex_t mutex; pthread_mutexattr_t mutexattr; pthread_cond_t cond; pthread_mutex_t start_mutex; pthread_cond_t start_cond; pthread_barrier_t barrier[2]; gboolean first_barrier; int wait_count[2]; pthread_t timelock_thread; pthread_mutex_t timelock_mutex; pthread_cond_t timelock_cond; pthread_mutex_t greedy_mutex; pthread_cond_t greedy_cond; pthread_mutex_t greedy_run_mutex; volatile guint locked_greedy; struct timespec timelock; GList *greedy_locks; pthread_mutex_t suspend_mutex; volatile gboolean critical_region; GObject *devout; AgsThread *parent; AgsThread *next; AgsThread *prev; AgsThread *children; gpointer data; };
struct AgsThreadClass { GObjectClass object; void (*start)(AgsThread *thread); void (*run)(AgsThread *thread); void (*suspend)(AgsThread *thread); void (*resume)(AgsThread *thread); void (*timelock)(AgsThread *thread); void (*stop)(AgsThread *thread); };
typedef enum { AGS_THREAD_RUNNING = 1, AGS_THREAD_IDLE = 1 << 1, AGS_THREAD_LOCKED = 1 << 2, AGS_THREAD_WAIT_FOR_PARENT = 1 << 3, AGS_THREAD_WAIT_FOR_SIBLING = 1 << 4, AGS_THREAD_WAIT_FOR_CHILDREN = 1 << 5, AGS_THREAD_WAIT_FOR_BARRIER = 1 << 6, AGS_THREAD_WAITING_FOR_PARENT = 1 << 7, AGS_THREAD_WAITING_FOR_SIBLING = 1 << 8, AGS_THREAD_WAITING_FOR_CHILDREN = 1 << 9, AGS_THREAD_WAITING_FOR_BARRIER = 1 << 10, AGS_THREAD_BROADCAST_PARENT = 1 << 11, AGS_THREAD_BROADCAST_SIBLING = 1 << 12, AGS_THREAD_BROADCAST_CHILDREN = 1 << 13, AGS_THREAD_INITIAL_RUN = 1 << 14, AGS_THREAD_TREE_SYNC_0 = 1 << 15, AGS_THREAD_WAIT_0 = 1 << 16, AGS_THREAD_TREE_SYNC_1 = 1 << 17, AGS_THREAD_WAIT_1 = 1 << 18, AGS_THREAD_TREE_SYNC_2 = 1 << 19, AGS_THREAD_WAIT_2 = 1 << 20, AGS_THREAD_TIMELOCK_RUN = 1 << 21, AGS_THREAD_TIMELOCK_WAIT = 1 << 22, AGS_THREAD_TIMELOCK_RESUME = 1 << 23, /* * prefered way would be unlocking greedy_locks * and the suspend to not become greedy * but while pthread_suspend and pthread_resume * are missing you need this as work-around */ AGS_THREAD_SKIP_NON_GREEDY = 1 << 24, AGS_THREAD_SKIPPED_BY_TIMELOCK = 1 << 25, AGS_THREAD_LOCK_GREEDY_RUN_MUTEX = 1 << 26, AGS_THREAD_SUSPENDED = 1 << 27, AGS_THREAD_SINGLE_LOOP = 1 << 28, AGS_THREAD_READY = 1 << 29, AGS_THREAD_UNREF_ON_EXIT = 1 << 30, } AgsThreadFlags;
void ags_accounting_table_set_sanity (,
GList *tableAgsThread *thread
,);
gdouble sanity
void ags_thread_add_child (AgsThread *thread
,AgsThread *child
);
Add child to thread.
|
an AgsThread |
|
the child to remove |
Since 0.4
gboolean ags_thread_children_is_locked (AgsThread *thread
);
Check the AGS_THREAD_LOCKED flag within sibling.
Since 0.4
AgsThread * ags_thread_first (AgsThread *thread
);
Retrieve first sibling.
Since 0.4
AgsThread * ags_thread_get_toplevel (AgsThread *thread
);
Retrieve toplevel thread.
Since 0.4
void ags_thread_hangcheck (AgsThread *thread
);
Performs hangcheck of thread.
Since 0.4
gboolean ags_thread_is_current_ready (AgsThread *current
,);
guint tic
AgsThread * ags_thread_last (AgsThread *thread
);
Retrieve last sibling.
Since 0.4
void ags_thread_lock (AgsThread *thread
);
Locks the threads own mutex and sets the appropriate flag.
Since 0.4
void ags_thread_lock_children (AgsThread *thread
);
Lock child tree structure.
Since 0.4
void ags_thread_lock_parent (AgsThread *thread
,AgsThread *parent
);
Lock parent tree structure.
Since 0.4
void ags_thread_lock_sibling (AgsThread *thread
);
Lock sibling tree structure.
Since 0.4
AgsThread * ags_thread_new (gpointer data
);
Create a new AgsThread you may provide a data
to your thread routine.
Since 0.4
AgsThread * ags_thread_next_children_locked (AgsThread *thread
);
Retrieve next locked thread following thread
Since 0.4
AgsThread * ags_thread_next_parent_locked (AgsThread *thread
,AgsThread *parent
);
Retrieve next locked thread above thread
.
Since 0.4
AgsThread * ags_thread_next_sibling_locked (AgsThread *thread
);
Retrieve next locked thread neighbooring thread
Since 0.4
gboolean ags_thread_parental_is_locked (AgsThread *thread
,AgsThread *parent
);
Check the AGS_THREAD_LOCKED flag in parental levels.
Since 0.4
void ags_thread_remove_child (AgsThread *thread
,AgsThread *child
);
Remove child of thread.
|
an AgsThread |
|
the child to remove |
Since 0.4
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 0.4
void ags_thread_set_sync (AgsThread *thread
,);
guint tic
Calls ags_thread_set_sync()
on all threads.
Since 0.4
gboolean ags_thread_sibling_is_locked (AgsThread *thread
);
Check the AGS_THREAD_LOCKED flag within sibling.
Since 0.4
void ags_thread_signal_children (AgsThread *thread
,);
gboolean broadcast
Signals the tree in lower levels.
Since 0.4
void ags_thread_signal_parent (AgsThread *thread
,AgsThread *parent
,);
gboolean broadcast
Signals the tree in higher levels.
Since 0.4
void ags_thread_signal_sibling (AgsThread *thread
,);
gboolean broadcast
Signals the tree on same level.
Since 0.4
void ags_thread_stop (AgsThread *thread
);
Stop the threads loop by unsetting AGS_THREAD_RUNNING flag.
Since 0.4
gboolean ags_thread_trylock (AgsThread *thread
);
Locks the threads own mutex if available and sets the
appropriate flag and returning TRUE
FALSE
|
an AgsThread |
Since 0.4
void ags_thread_unlock (AgsThread *thread
);
Unlocks the threads own mutex and unsets the appropriate flag.
Since 0.4
void ags_thread_unlock_children (AgsThread *thread
);
Unlock child tree structure.
Since 0.4
void ags_thread_unlock_parent (AgsThread *thread
,AgsThread *parent
);
Unlock parent tree structure.
Since 0.4
void ags_thread_unlock_sibling (AgsThread *thread
);
Unlock sibling tree structure.
Since 0.4
void ags_thread_wait_children (AgsThread *thread
);
Wait on child tree structure.
Since 0.4
void ags_thread_wait_parent (AgsThread *thread
,AgsThread *parent
);
Wait on parent tree structure.
Since 0.4
void ags_thread_wait_sibling (AgsThread *thread
);
Wait on sibling tree structure.
Since 0.4