summaryrefslogtreecommitdiff
path: root/Source/modules/asura-base/FileSystem/IOTask.h
blob: c2a22bab73dc3ce3d63919c39c535e276a2c0101 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef _ASURA_IO_TASK_H_
#define _ASURA_IO_TASK_H_

#include <string>

#include "../Scripting/Scripting.h"
#include "../Threads/Task.h"

#include "DataBuffer.h"

namespace_begin(AsuraEngine)
namespace_begin(FileSystem)

enum IOTaskType
{
	IOTASK_TYPE_READ, 
	IOTASK_TYPE_WRITE,
	IOTASK_TYPE_APPEND,
};

///
/// ȡļ
///
class IOTask ASURA_FINAL
	: public AEScripting::Portable<IOTask, AEThreading::Task>
{
public:

	LUAX_DECL_FACTORY(IOTask);

	IOTask(const std::string& path, DataBuffer* buffer, IOTaskType type);
	~IOTask();

	bool Execute() override ;
	void Invoke(lua_State* invokeThreaad) override;

private:

	LUAX_DECL_ENUM(IOTaskType);

	LUAX_DECL_METHOD(_New);

	std::string m_Path;
	IOTaskType  m_Type;

	DataBuffer*         m_Buffer;
	Luax::LuaxMemberRef m_BufferRef;

};

namespace_end
namespace_end

#endif