Dee.SharedModel¶
- Subclasses:
None
Methods¶
- Inherited:
Dee.SerializableModel (3), GObject.Object (37), Dee.Model (48), Dee.Serializable (4)
- Structs:
class |
|
class |
|
class |
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
Access mode used by this shared model |
||
r/w |
Determines whether flushes occur automatically |
||
r/w/co |
The peer object that monitors the swarm |
||
r |
Whether the model is synchronized with its peers |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted right before a remote transaction will be committed to the model. |
|
Emitted right after a remote transaction has been committed to the model. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
||
priv |
r |
Class Details¶
- class Dee.SharedModel(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
All fields in the
Dee.SharedModel
structure are private and should never be accessed directly- classmethod new(name)¶
- Parameters:
name (
str
) – A well known name to publish this model under. Models sharing this name will synchronize with each other- Returns:
a new
Dee.SharedModel
- Return type:
Create a new empty shared model without any column schema associated. The column schema will be set in one of two ways: firstly you may set it manually with dee_model_set_schema() or secondly it will be set once the first rows are exchanged with a peer model.
A
Dee.SharedModel
with a schema manually set has to be created before creating moreDee.SharedModel
with the same name.A shared model created with this constructor will store row data in a suitably picked memory backed model.
- classmethod new_for_peer(peer)¶
- Parameters:
- Returns:
a new
Dee.SharedModel
- Return type:
Create a new empty shared model without any column schema associated. The column schema will be set in one of two ways: firstly you may set it manually with dee_model_set_schema() or secondly it will be set once the first rows are exchanged with a peer model.
A
Dee.SharedModel
with a schema manually set has to be created before creating moreDee.SharedModel
with the same name.A shared model created with this constructor will store row data in a suitably picked memory backed model.
- classmethod new_with_back_end(name, back_end)¶
- Parameters:
- Returns:
a new
Dee.SharedModel
- Return type:
Create a new shared model storing all data in back_end.
The model will start synchronizing with peer models as soon as possible and the
Dee.SharedModel
:synchronized
property will be set once finished.
- flush_revision_queue()¶
- Returns:
The number of revisions flushed.
- Return type:
Expert: All changes to self that has not yet been propagated to the peer models are send. If you also want to block the mainloop until all the underlying transport streams have been flushed use
Dee.SharedModel.flush_revision_queue_sync
().Normally
Dee.SharedModel
collects changes to self into batches and sends them automatically to all peers. You can use this call to provide fine grained control of exactly when changes to self are synchronized to its peers. This may for example be useful to improve the interactivity of your application if you have a model-process which intermix small and light changes with big and expensive changes. Using this call you can make sure the model-process dispatches small changes more aggresively to the view-process, while holding on to the expensive changes a bit longer.
- flush_revision_queue_sync()¶
- Returns:
The number of revisions flushed.
- Return type:
Similar to
Dee.SharedModel.flush_revision_queue
(), but also blocks the mainloop until all the underlying transport streams have been flushed.Important: This method may flush your internal queue of DBus messages forcing them to be send before this call returns.
- get_flush_mode()¶
- Returns:
The
Dee.SharedModelFlushMode
used by the model- Return type:
Convenience function for accessing the
Dee.SharedModel
:flush-mode
property.
- get_peer()¶
-
Convenience function for accessing the
Dee.SharedModel
:peer
property
- get_swarm_name()¶
- Returns:
The name of the swarm this model synchrnonizes with
- Return type:
Convenience function for accessing the
Dee.Peer
:swarm-name
property of theDee.Peer
defined in theDee.SharedModel
:peer
property.
- is_leader()¶
- Returns:
The value of
Dee.Peer.is_swarm_leader
() for theDee.Peer
used by this shared model- Return type:
Check if the model is the swarm leader. This is a convenience function for accessing the
Dee.SharedModel
:peer
property and checking if it’s the swarm leader.
- is_synchronized()¶
- Returns:
The value of the
:synchronized
property- Return type:
Check if the model is synchronized with its peers. Before modifying a shared model in any way (except dee_model_set_schema()) you should wait for it to become synchronized. This is normally done by waiting for the “notify::synchronized” signal.
This method is purely a convenience function for accessing the
Dee.SharedModel
:synchronized
property.
- set_flush_mode(mode)¶
- Parameters:
mode (
Dee.SharedModelFlushMode
) – Flush mode to use
Convenience function for setting the
Dee.SharedModel
:flush-mode
property.
Signal Details¶
- Dee.SharedModel.signals.begin_transaction(shared_model, begin_seqnum, end_seqnum)¶
- Signal Name:
begin-transaction
- Flags:
- Parameters:
shared_model (
Dee.SharedModel
) – The object which received the signalbegin_seqnum (
int
) – The seqnum the model has nowend_seqnum (
int
) – The seqnum the model will have after the transaction is applied
Emitted right before a remote transaction will be committed to the model.
- Dee.SharedModel.signals.end_transaction(shared_model, begin_seqnum, end_seqnum)¶
- Signal Name:
end-transaction
- Flags:
- Parameters:
shared_model (
Dee.SharedModel
) – The object which received the signalbegin_seqnum (
int
) – The seqnum the model had before the transaction was appliedend_seqnum (
int
) – The seqnum the model has now
Emitted right after a remote transaction has been committed to the model.
Property Details¶
- Dee.SharedModel.props.access_mode¶
- Name:
access-mode
- Type:
- Default Value:
- Flags:
Enumeration defining behavior of this model when trying to write to it.
Setting this to
Dee.SharedModelAccessMode.LEADER_WRITABLE
is useful when one process is considered an “owner” of a model and all the other peers are supposed to only synchronize it for reading.See also
Dee.Peer
:swarm-owner
property to ensure ownership of a swarm.
- Dee.SharedModel.props.flush_mode¶
- Name:
flush-mode
- Type:
- Default Value:
- Flags:
Enumeration defining the flushing behavior.
Setting this to
Dee.SharedModelFlushMode.MANUAL
will disable automatic flushing that usually happens when the application’s main event loop is idle. Automatic flushing should be primarily disabled when a shared model is used from multiple threads, or when not usingGLib.MainLoop
. When disabled,Dee.SharedModel.flush_revision_queue
() needs to be called explicitely.
- Dee.SharedModel.props.peer¶
- Name:
peer
- Type:
- Default Value:
- Flags:
The
Dee.Peer
that this model uses to connect to the swarm
- Dee.SharedModel.props.synchronized¶
-
Boolean property defining whether or not the model has synchronized with its peers (if any) yet.
You should not modify a
Dee.SharedModel
that is not synchronized. Before modifying the model in any way (except calling dee_model_set_schema()) you should wait for it to become synchronized.