summaryrefslogtreecommitdiff
path: root/source/modules/asura-utils/io/io_task.h
blob: 8026a24493aaae02599170886856e5f21a4666ea (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
55
56
#ifndef __ASURA_IO_TASK_H__
#define __ASURA_IO_TASK_H__

#include <string>

#include "../scripting/portable.hpp"
#include "../threading/task.h"

#include "data_buffer.h"

namespace AsuraEngine
{
	namespace IO
	{

		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;

		};

	}
}

#endif