summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-utils/io/io_task.h
blob: 5f454ee1cf6c39092ca4623de101f5ee6d4c2130 (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
57
#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 AEThreading::Task
			, public AEScripting::Portable<IOTask>
		{
		public:

			LUAX_DECL_FACTORY(IOTask);

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

			bool Execute() override ;
			void Invoke() override;

		private:

			LUAX_DECL_ENUM(IOTaskType);

			LUAX_DECL_METHOD(_New);

			std::string mPath;
			IOTaskType  mType;

			ASURA_REF DataBuffer* mBuffer;
			Luax::LuaxMemberRef   mBufferRef;

		};

	}
}

#endif