* Added node locking related flags.
* Added convenience method StartAndAddNode(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37505 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -59,6 +59,17 @@ Transaction::Start()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Transaction::StartAndAddNode(Node* node, uint32 flags = 0)
|
||||
{
|
||||
status_t error = Start();
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
return AddNode(node, flags);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Transaction::Commit()
|
||||
{
|
||||
@@ -128,7 +139,8 @@ Transaction::AddNode(Node* node, uint32 flags)
|
||||
if (info == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
node->WriteLock();
|
||||
if ((flags & TRANSACTION_NODE_ALREADY_LOCKED) == 0)
|
||||
node->WriteLock();
|
||||
|
||||
info->node = node;
|
||||
info->oldNodeData = node->NodeData();
|
||||
@@ -189,7 +201,7 @@ Transaction::_DeleteNodeInfosAndUnlock(bool failed)
|
||||
while (NodeInfo* info = fNodeInfos.RemoveHead()) {
|
||||
if ((info->flags & TRANSACTION_DELETE_NODE) != 0)
|
||||
delete info->node;
|
||||
else
|
||||
else if ((info->flags & TRANSACTION_KEEP_NODE_LOCKED) == 0)
|
||||
info->node->WriteUnlock();
|
||||
delete info;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ class Volume;
|
||||
|
||||
|
||||
enum {
|
||||
TRANSACTION_DELETE_NODE = 0x1
|
||||
TRANSACTION_DELETE_NODE = 0x1,
|
||||
TRANSACTION_NODE_ALREADY_LOCKED = 0x2,
|
||||
TRANSACTION_KEEP_NODE_LOCKED = 0x4
|
||||
};
|
||||
|
||||
|
||||
@@ -29,6 +31,7 @@ public:
|
||||
int32 ID() const { return fID; }
|
||||
|
||||
status_t Start();
|
||||
status_t StartAndAddNode(Node* node, uint32 flags = 0);
|
||||
status_t Commit();
|
||||
void Abort();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user