2 * Copyright 2012, Rene Gollent, rene@gollent.com.
3 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
4 * Distributed under the terms of the MIT License.
9 #include <AutoLocker.h>
12 #include "TeamMemory.h"
13 #include "TeamMemoryBlock.h"
16 RetrieveMemoryBlockJob::RetrieveMemoryBlockJob(Team
* team
,
17 TeamMemory
* teamMemory
, TeamMemoryBlock
* memoryBlock
)
19 fKey(memoryBlock
, JOB_TYPE_GET_MEMORY_BLOCK
),
21 fTeamMemory(teamMemory
),
22 fMemoryBlock(memoryBlock
)
24 fTeamMemory
->AcquireReference();
25 fMemoryBlock
->AcquireReference();
29 RetrieveMemoryBlockJob::~RetrieveMemoryBlockJob()
31 fTeamMemory
->ReleaseReference();
32 fMemoryBlock
->ReleaseReference();
37 RetrieveMemoryBlockJob::Key() const
44 RetrieveMemoryBlockJob::Do()
46 ssize_t result
= fTeamMemory
->ReadMemory(fMemoryBlock
->BaseAddress(),
47 fMemoryBlock
->Data(), fMemoryBlock
->Size());
49 fMemoryBlock
->NotifyDataRetrieved(result
);
53 uint32 protection
= 0;
55 status_t error
= fTeamMemory
->GetMemoryProperties(
56 fMemoryBlock
->BaseAddress(), protection
, locking
);
58 fMemoryBlock
->NotifyDataRetrieved(error
);
62 fMemoryBlock
->SetWritable((protection
& B_WRITE_AREA
) != 0);
63 fMemoryBlock
->MarkValid();