Movatterモバイル変換


[0]ホーム

URL:


CN114428687A - A method for canceling encryption and decryption tasks under the iOS platform and related equipment - Google Patents

A method for canceling encryption and decryption tasks under the iOS platform and related equipment
Download PDF

Info

Publication number
CN114428687A
CN114428687ACN202011185235.4ACN202011185235ACN114428687ACN 114428687 ACN114428687 ACN 114428687ACN 202011185235 ACN202011185235 ACN 202011185235ACN 114428687 ACN114428687 ACN 114428687A
Authority
CN
China
Prior art keywords
task
encryption
decryption
cancellation
class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011185235.4A
Other languages
Chinese (zh)
Inventor
周志刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co LtdfiledCriticalWuhan Douyu Network Technology Co Ltd
Priority to CN202011185235.4ApriorityCriticalpatent/CN114428687A/en
Publication of CN114428687ApublicationCriticalpatent/CN114428687A/en
Pendinglegal-statusCriticalCurrent

Links

Images

Classifications

Landscapes

Abstract

Translated fromChinese

本发明提供了一种iOS平台下加解密任务取消的方法,包括:创建包括加解密任务请求回调接口的任务类,以实现加解密任务的取消;创建具有状态变量的封装类,所述封装类内包含有传递对象,以向调用者提供任务取消命令接口和/或数据接口;创建包装类,并对所述封装类进行包装,使不同程序语言架构下的调用函数持有同一份封装类的传递对象,实现不同程序语言之间传递对象的互相调用,还提供了一种电子设备和计算机介质。

Figure 202011185235

The present invention provides a method for canceling an encryption and decryption task under the iOS platform, including: creating a task class including an encryption and decryption task request callback interface to realize the cancellation of the encryption and decryption task; creating an encapsulation class with state variables, the encapsulation class It contains a transfer object to provide the caller with a task cancellation command interface and/or data interface; create a wrapper class, and wrap the wrapper class so that calling functions under different programming language architectures hold the same copy of the wrapper class. The transfer object realizes the mutual call of the transfer object between different programming languages, and also provides an electronic device and a computer medium.

Figure 202011185235

Description

Translated fromChinese
一种iOS平台下加解密任务取消的方法及相关设备A method for canceling encryption and decryption tasks under the iOS platform and related equipment

技术领域technical field

本发明涉及软件操作系统控制技术领域,尤其涉及一种iOS平台下加解密任务取消的方法及相关设备。The invention relates to the technical field of software operating system control, in particular to a method and related equipment for canceling encryption and decryption tasks under an iOS platform.

背景技术Background technique

现有操作系统中,可以直接通过加解密任务的接口来调用任务的取消功能实现加解密任务的取消。但是在ios平台上,对于网络库来说基本都是基于系统网络库来开发,其对应的语言是object-c,任务的请求和取消发起者是应用层功能object-c语言来调用,而底层加解密请求是C++层编写,需要在二种语言之间设计一个任务取消的功能。而二种语言不一样,对于每个对象的生命周期也不一样,设计上需要考虑二者语言的生命周期,以及对象的管理,不能造成内测泄露。In the existing operating system, the cancellation function of the task can be called directly through the interface of the encryption and decryption task to realize the cancellation of the encryption and decryption task. However, on the ios platform, the network library is basically developed based on the system network library. The corresponding language is object-c. The request and cancellation initiator of the task is called by the application layer function object-c language, while the underlying language is object-c. The encryption and decryption request is written in the C++ layer, and a task cancellation function needs to be designed between the two languages. The two languages are different, and the life cycle of each object is also different. The design needs to consider the life cycle of the two languages and the management of objects, so as not to cause internal testing leakage.

现有或者传统方案都会采取加解密任务id的方案来取消任务请求,或者是任务完成后来标记其是一个取消的任务,只能够大粒度的取消,没有办法精确到任务的各个阶段,取消任务没有取消是否成功的事件回执,从而调用取消者无法知道状态,取消功能需要遍历任务队列,从而造成了遍历的开销。存在极端情况,造成应用层出错的情况,因此需要一种方案来设计出安全可靠稳定的使用方案能够实现两种调用对象之间互相调用的功能。Existing or traditional solutions will adopt the solution of encrypting and decrypting task id to cancel the task request, or mark it as a canceled task after the task is completed, which can only be canceled in large-scale, and there is no way to be accurate to each stage of the task. The event receipt of whether the cancellation is successful or not, so the caller cannot know the status, and the cancellation function needs to traverse the task queue, which causes the overhead of traversal. There are extreme cases that cause errors at the application layer. Therefore, a solution is needed to design a safe, reliable and stable usage solution that can realize the function of calling each other between the two calling objects.

发明内容SUMMARY OF THE INVENTION

本发明提供了一种iOS平台下加解密任务取消的方法,将调用命令接口作为传递对象进行封装,并对传递对象进行包装,使不同程序语言架构下的调用函数持有同一份封装类的传递对象,实现不同程序语言之间封装类传递对象的互相调用,避免应用层出错。The invention provides a method for canceling encryption and decryption tasks under the iOS platform, encapsulates the calling command interface as a transfer object, and wraps the transfer object, so that calling functions under different programming language architectures hold the same encapsulation class for transfer Object, realizes the mutual call of encapsulated class transfer objects between different programming languages, and avoids application layer errors.

本发明还有一个目的是在回调接口内创建表示加解密任务执行结果和任务状态的参数以及状态码,精细化加密任务取消功能的各阶段的细节,使调用者精确感知加密任务取消功能的执行状态。Another object of the present invention is to create parameters and status codes representing the execution result and task status of the encryption/decryption task in the callback interface, so as to refine the details of each stage of the encryption task cancellation function, so that the caller can accurately perceive the execution of the encryption task cancellation function. state.

本发明提供的技术方案为:The technical scheme provided by the present invention is:

一种iOS平台下加解密任务取消的方法,包括:A method for canceling an encryption and decryption task under the iOS platform, comprising:

创建包括加解密任务请求回调接口的任务类,以实现加解密任务的取消;Create a task class including the encryption and decryption task request callback interface to cancel the encryption and decryption tasks;

创建具有状态变量的封装类,所述封装类内包含有传递对象,以向调用者提供任务取消命令接口和/或数据接口;Create an encapsulation class with state variables, the encapsulation class contains a transfer object to provide the caller with a task cancellation command interface and/or a data interface;

创建包装类,并对所述封装类进行包装,使不同程序语言架构下的调用函数持有同一份封装类的传递对象,实现不同程序语言之间传递对象的互相调用。A wrapper class is created, and the wrapper class is packaged, so that the calling functions under different programming language frameworks hold the same transfer object of the wrapper class, so as to realize the mutual calling of transfer objects between different programming languages.

优选的是,所述任务类的创建过程包括:Preferably, the creation process of the task class includes:

在所述回调接口内创建表示加解密任务执行结果和任务状态的参数,以实现各回调接口的功能;Create parameters representing the execution result of the encryption/decryption task and the task status in the callback interface, so as to realize the function of each callback interface;

其中,所述回调接口包括加解密执行成功的回调接口、加解密出错的回调接口和任务实际取消的回调接口;以及The callback interface includes a callback interface for successful encryption and decryption execution, a callback interface for encryption and decryption errors, and a callback interface for actually canceling the task; and

创建所述任务状态参数的状态集合,所述状态集合内包含标记任务状态的状态码;Create a state set of the task state parameters, the state set contains a state code marking the task state;

其中,所述状态码表示加解密任务执行结果和任务状态,并包括加解密任务准备中、生成加解密密钥中、加解密数据准备中、数据加密中、数据解密中、任务已经取消、任务成功和任务取消中的一种或多种。The status code represents the execution result and task status of the encryption and decryption task, and includes the encryption and decryption task in preparation, encryption and decryption key generation, encryption and decryption data preparation, data encryption, data decryption, task canceled, task One or more of success and task cancellation.

优选的是,所述封装类的创建过程包括:Preferably, the creation process of the encapsulation class includes:

构造封装函数;Construct wrapper function;

在所述封装类内设置取消命令接口,调用者通过所述取消命令接口实现加解密任务的取消;A cancellation command interface is set in the encapsulation class, and the caller realizes the cancellation of the encryption and decryption tasks through the cancellation command interface;

并在所述封装类内设置查询取消接口,调用者通过所述所述查询取消命令接口,实现加解密任务的查询命令取消;And a query cancellation interface is set in the encapsulation class, and the caller realizes the cancellation of the query command of the encryption and decryption task through the query cancellation command interface;

其中,所述取消命令接口内设置有状态变量,所述状态变量使用布尔型原子变量,并包括取消状态变量和不取消状态变量。Wherein, a state variable is set in the cancel command interface, and the state variable uses a Boolean atomic variable, and includes a cancel state variable and a non-cancel state variable.

优选的是,所述包装类的创建过程包括:Preferably, the creation process of the wrapper class includes:

定义成员变量,建立不控制对象生命周期的弱引用智能指针,所述弱引用智能指针持有所述封装类,将所述封装类内的传递对象作为管理对象;Define a member variable, establish a weak reference smart pointer that does not control the life cycle of the object, the weak reference smart pointer holds the encapsulation class, and the transfer object in the encapsulation class is used as a management object;

构造赋值函数,对封装类内的加解密取消任务的传递对象赋值得到赋值对象,并且建立参数将所述赋值对象传入弱引用智能指针;Constructing an assignment function, assigning a value to the transfer object of the encryption/decryption cancellation task in the encapsulation class to obtain an assignment object, and establishing a parameter to pass the assignment object into a weak reference smart pointer;

建立取消接口,通过所述弱引用智能指针检测所传递对象否被C++层释放,若没有被释放,执行取消任务;Establish a cancellation interface, detect whether the passed object is released by the C++ layer through the weak reference smart pointer, and execute the cancellation task if it is not released;

建立查询取消接口,通过所述弱引用智能指针检测所述传递对象时否被C++层释放,若没有被释放,执行查询取消任务。A query cancellation interface is established, and whether the passed object is released by the C++ layer is detected through the weak reference smart pointer, and if it is not released, the query cancellation task is performed.

优选的是,还包括:Preferably, it also includes:

当调用者通过取消命令接口和/或查询取消命令接口提出加解密任务取消请求时,C++层返回一个取消任务对象句柄,进而调用对应的任务回调接口,执行取消功能。When the caller makes an encryption/decryption task cancellation request through the cancel command interface and/or the query cancel command interface, the C++ layer returns a cancel task object handle, and then calls the corresponding task callback interface to execute the cancel function.

优选的是,所述C++层取消任务对象句柄的接口构建过程包括:Preferably, the interface construction process of the C++ layer canceling the task object handle includes:

建立引用计数型智能指针,所述引用计数型智能指针持有所述封装类内的传递对象,能够对所述传递对象创建和销毁;establishing a reference counting smart pointer, the reference counting smart pointer holds the transfer object in the encapsulation class, and can create and destroy the transfer object;

建立所述封装类的共享指针,并返回调用者一个对应的弱引用智能指针的管理对象;establishing the shared pointer of the encapsulation class, and returning a corresponding weak reference smart pointer management object to the caller;

其中,所述弱引用智能指针的管理对象返回调用者时,采用拷贝操作返回,使C++层和调用者使用同一份传递对象。Wherein, when the management object of the weak reference smart pointer is returned to the caller, a copy operation is used to return, so that the C++ layer and the caller use the same transfer object.

优选的是,还包括加解密任务取消状态参数的检查复核,其通过以下步骤实现:Preferably, it also includes the check and review of the cancellation state parameter of the encryption and decryption tasks, which is realized by the following steps:

建立复核类,并将所述解密任务取消的传递对象、所述解密任务取消对应的状态和任务回调对象作为成员变量;A review class is established, and the transfer object of the cancellation of the decryption task, the state corresponding to the cancellation of the decryption task, and the task callback object are used as member variables;

建立对象构造函数,检测所述解密任务取消的传递对象是否内部取消;establishing an object constructor to detect whether the transfer object canceled by the decryption task is canceled internally;

若取消,回调任务取消,传入对用的状态参数,并告知调用者。If it is canceled, the callback task is canceled, the corresponding state parameter is passed in, and the caller is notified.

一种具有iOS平台下加解密任务取消功能的装置,包括:A device with the function of canceling encryption and decryption tasks under the iOS platform, comprising:

功能模块,其用于创建包括加解密任务请求回调接口的任务类,以实现加解密任务的取消;A function module, which is used to create a task class including an encryption and decryption task request callback interface, so as to realize the cancellation of the encryption and decryption task;

封装模块,其用于创建具有状态变量的封装类,所述封装类内包含有传递对象,以向调用者提供任务取消接口和/或数据接口;an encapsulation module, which is used to create an encapsulation class with state variables, the encapsulation class contains a transfer object to provide a caller with a task cancellation interface and/or a data interface;

包装模块,并对所述封装类进行包装,使不同程序语言架构下的调用函数持有同一份封装类的传递对象,实现不同程序语言之间封装类传递对象的互相调用。The packaging module wraps the encapsulation class, so that the calling functions under different programming language frameworks hold the same encapsulation class transfer object, and realizes the mutual call of the encapsulation class transfer objects between different programming languages.

一种电子设备,包括应用处理器和存储器,所述处理器用于存储器中计算机管理程序式实现所述iOS平台下加解密任务取消方法的步骤。An electronic device includes an application processor and a memory, wherein the processor is used in the memory to implement the steps of the encryption and decryption task cancellation method under the iOS platform in a computer management program.

一种计算机可读存储介质,其上存储有计算机管理类程序,所述计算机管理类程序被处理器执行时实现所述iOS平台下加解密任务取消的方法的步骤。A computer-readable storage medium is stored thereon with a computer management program, and when the computer management program is executed by a processor, the steps of the method for canceling encryption and decryption tasks under the iOS platform are implemented.

有益效果beneficial effect

本发明提供了一种iOS平台下加解密任务取消的方法,将调用命令接口作为传递对象进行封装,并对传递对象进行包装,使不同程序语言架构下的调用函数持有同一份封装类的传递对象,实现不同程序语言之间封装类传递对象的互相调用,避免应用层出错。The invention provides a method for canceling encryption and decryption tasks under the iOS platform, encapsulates the calling command interface as a transfer object, and wraps the transfer object, so that calling functions under different programming language architectures hold the same encapsulation class for transfer Object, realizes the mutual call of encapsulated class transfer objects between different programming languages, and avoids application layer errors.

本发明提供的任务状态参数内具有标记任务状态的状态码,以细化加解密的任务阶段,从而更精细化到加解密任务的各个阶段,通过状态码可以实现加解密任务的各个阶级的取消,从而粒度更细,性能更好,减少了不必要的计算。The task state parameter provided by the present invention has a state code marking the task state, so as to refine the task stage of encryption and decryption, so as to be more refined to each stage of the encryption and decryption task, and the cancellation of each stage of the encryption and decryption task can be realized through the state code. , resulting in finer granularity, better performance, and less unnecessary computation.

本发明设计传递接口对象,而不是把整个加密任务都返回给调用者,目的是减少调用者对加密任务的细节的感知,从而减少其对加密任务的操控,将其需要的最小的粒度的数据给到调用者,不将加接密的各个阶段的数据暴露出去,避免调用者访问,减少出错的可能性。The present invention is designed to pass the interface object instead of returning the entire encryption task to the caller. The purpose is to reduce the caller's perception of the details of the encryption task, thereby reducing its manipulation of the encryption task and converting the data of the smallest granularity it needs. To the caller, the data at various stages of encryption and encryption are not exposed to avoid the caller's access and reduce the possibility of errors.

附图说明Description of drawings

图1为本发明所述的iOS平台下加解密任务取消的方法流程图。1 is a flowchart of a method for canceling encryption and decryption tasks under the iOS platform according to the present invention.

图2为本发明所述的包装类的创建流程图。FIG. 2 is a flow chart of the creation of the wrapper class according to the present invention.

图3为本发明所述的具有iOS平台下加解密任务取消功能的装置的示意图。FIG. 3 is a schematic diagram of the device with the function of canceling encryption and decryption tasks under the iOS platform according to the present invention.

图4为本申请实施例提供的具有iOS平台下加解密任务取消功能的装置的硬件结构示意图;4 is a schematic diagram of the hardware structure of a device with an encryption and decryption task cancellation function under an iOS platform provided by an embodiment of the present application;

图5为本申请实施例提供的一种可能的电子设备的实施例示意图。FIG. 5 is a schematic diagram of an embodiment of a possible electronic device provided by an embodiment of the present application.

图6为本申请实施例提供的一种可能的计算机可读存储介质的实施例示意图。FIG. 6 is a schematic diagram of an embodiment of a possible computer-readable storage medium provided by an embodiment of the present application.

具体实施方式Detailed ways

以下由特定的具体实施例说明本发明的实施方式,熟悉此技术的人士可由本说明书所揭露的内容轻易地了解本发明的其他优点及功效,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The embodiments of the present invention are described below by specific specific embodiments. Those who are familiar with the technology can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are part of the present invention. , not all examples. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

需要说明的是,在本发明的描述中,术语“中”、“上”、“下”、“横”、“内”等指示的方向或位置关系的术语是基于附图所示的方向或位置关系,这仅仅是为了便于描述,而不是指示或暗示所述装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本发明的限制。此外,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性。It should be noted that, in the description of the present invention, the terms "middle", "upper", "lower", "horizontal", "inner", etc. indicate directions or terms in positional relationship based on the directions shown in the drawings or The positional relationship is only for the convenience of description, rather than indicating or implying that the device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed to indicate or imply relative importance.

此外,还需要说明的是,在本发明的描述中,除非另有明确的规定和限定,术语“设置”、“安装”、“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接;可以是机械连接;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通。对于本领域技术人员而言,可根据具体情况理解上述术语在本发明中的具体含义。In addition, it should be noted that, in the description of the present invention, unless otherwise expressly specified and limited, the terms "arranged", "installed", "connected" and "connected" should be understood in a broad sense, for example, it may be fixed The connection can also be a detachable connection, or an integral connection; it can be a mechanical connection; it can be a direct connection, or an indirect connection through an intermediate medium, and it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific situations.

如图1所示,基于背景技术提出的技术问题,本发明提供了一种iOS平台下加解密任务取消的方法,包括如下步骤:As shown in Figure 1, based on the technical problem proposed by the background technology, the present invention provides a method for canceling encryption and decryption tasks under an iOS platform, comprising the following steps:

步骤S110、创建包括加解密任务请求回调接口的任务类,以实现加解密任务的取消。具体的说,设计一个加密任务请求的回调接口,其中包含加密任务过程中的各个阶段,同时也包含任务取消功能的取消成功回调。以任务回调的方式则更易于完成取消功能,并且易于解决极端的异步线程调用时序导致取消任务是在任务执行完成后才触发。具体的程序语言如下:Step S110 , creating a task class including an encryption/decryption task request callback interface, so as to realize the cancellation of the encryption/decryption task. Specifically, a callback interface for an encryption task request is designed, which includes various stages in the encryption task process, as well as the successful cancellation callback of the task cancellation function. It is easier to complete the cancellation function in the way of task callback, and it is easy to solve the extreme asynchronous thread call timing, which causes the cancellation of the task to be triggered after the task execution is completed. The specific programming language is as follows:

Class Callback{Class Callback{

virtual~Callback()=default;virtual~Callback()=default;

virtual void OnSucceeded(Ressult*result,Status s)=0;virtual void OnSucceeded(Ressult*result,Status s)=0;

virtual void OnError(exception*ex,Status s)=0;virtual void OnError(exception*ex,Status s)=0;

Virtual void OnCancel(Status s);=0;}Virtual void OnCancel(Status s); = 0; }

其中,Class Callback{即设计一个任务回调接口类;virtual~Callback()=default即虚席构函数,能够防止内存泄露。virtual void OnSucceeded(Ressult*result,Status s)=0;加解密执行成功的回调函数设计,参数result代表执行的结果,status代表任务的状态。virtual void OnError(exception*ex,Status s)=0为加解密出错的回调函数;Virtual void OnCancel(Status s);=0;任务实际取消的回调。此接口则可以当任务真正取消的时候来告知应用层任务取消。Among them, Class Callback{ is to design a task callback interface class; virtual~Callback()=default is the virtual seat constructor, which can prevent memory leaks. virtual void OnSucceeded(Ressult*result, Status s)=0; The callback function design for successful encryption and decryption execution, the parameter result represents the execution result, and the status represents the status of the task. virtual void OnError(exception*ex, Status s)=0 is the callback function for encryption and decryption errors; Virtual void OnCancel(Status s);=0; the callback for the actual cancellation of the task. This interface can inform the application layer task to cancel when the task is really canceled.

其中,任务状态参数内具有标记任务状态的状态码,以细化加解密的任务阶段;具体的说,设计加密任务的状态码来标记任务的当前状态,从而业务层ojbect-c则可以在取消任务和非取消任务时能够知道任务的状态,在本实施例中,给出了具体的程序语言举例,具体内容如下:Among them, the task status parameter has a status code that marks the status of the task to refine the task phase of encryption and decryption; specifically, the status code of the encryption task is designed to mark the current status of the task, so that the business layer ojbect-c can cancel the The state of the task can be known when the task and the non-cancellation task are. In this embodiment, a specific programming language example is given, and the specific content is as follows:

Enmu Status{Enmu Status{

Prepare=0,Prepare=0,

key,key,

data,data,

Encrypt,Encrypt,

Decrypt,Decrypt,

Cancel,Cancel,

Suces,Suces,

Error}Error}

其中状态码与任务状态相对应,Prepare=0,表示加解密任务准备中;key,表示:生成加解密密钥中;data表示加解密数据准备中;Encrypt表示数据加密中;Decrypt表示数据解密中;Cancel表示任务已经取消;Suces,任务成功Error表示任务取消。The status code corresponds to the task status, Prepare=0, indicating that the encryption and decryption task is in preparation; key, indicating that the encryption and decryption key is being generated; data indicates that the encryption and decryption data is being prepared; Encrypt indicates that the data is being encrypted; Decrypt indicates that the data is being decrypted. ;Cancel indicates that the task has been canceled; Suces, the task is successful Error indicates that the task is canceled.

在本实施例中定义这些状态,精细化到加解密任务的各个阶段,从而加解密任务的各个阶级都可以进行取消,粒度更细,性能更好,避免任务取消而去过多的执行了不必要的计算。In this embodiment, these states are defined and refined to each stage of the encryption and decryption tasks, so that all levels of the encryption and decryption tasks can be canceled, the granularity is finer, and the performance is better. necessary calculations.

步骤S120、创建具有状态变量的封装类,封装类内包含有传递对象,以向调用者提供任务取消命令接口和/或数据接口;Step S120, creating an encapsulation class with a state variable, and the encapsulation class contains a transfer object to provide the caller with a task cancellation command interface and/or a data interface;

具体地说,在设计一个加密任务的请求时,会给调用者返回一个hanlder对象,handler对象则提供了取消任务的功能,本实施例中设计handler,而不是把整个加密任务都返回给调用者,目的是减少调用者对加密任务的细节的感知,从而减少其对加密任务的操控,将其需要的最小的粒度的数据给到调用者,因此本发明设计了取消任务的最小粒度数据的方案,而对于例如加密的各个阶段的数据等不暴露出去,从而其也无法进行访问,减少出错的可能性。其中,handler即为传递对象,向调用者任务取消命令接口和/或数据接口,调用者可以通过接口实现加解密任务的取消功能。Specifically, when designing a request for an encryption task, a handler object will be returned to the caller, and the handler object provides the function of canceling the task. In this embodiment, the handler is designed instead of returning the entire encryption task to the caller. , the purpose is to reduce the caller's perception of the details of the encryption task, thereby reducing its manipulation of the encryption task, and giving the caller the smallest granularity data it needs. Therefore, the present invention designs a scheme to cancel the smallest granularity data of the task. , and for example, data at various stages of encryption are not exposed, so that it cannot be accessed, reducing the possibility of errors. Among them, the handler is the transfer object, which cancels the command interface and/or the data interface to the caller task, and the caller can realize the cancellation function of the encryption and decryption task through the interface.

创建封装类的程序语言的设计如下:The programming language for creating encapsulated classes is designed as follows:

Class THandle{Class THandle{

atomic<bool>flag_{false};。atomic<bool>flag_{false};.

THandle(){}构造函数。THandle(){} constructor.

void cancel(){flag_=true;}void cancel(){flag_=true;}

bool isCancel()const{return flag_;}bool isCancel() const {return flag_;}

其中,Class THandle{即为创建一个THandle类来封装取消的功能和数据。atomic<bool>flag_{false};其中成员变量只有一个flag_变量,在本实施例中使用原子变量,并且使用bool类型,可以表达取消和不取消两种状态,同时由于的flag_变量会给到底层的加密算法来访问,底层是多线程的访问,而调用者object-c也可能会使用异步线程来取消,传统方案可能使用加锁方案,使用原子变量,则可以规避多线程加锁,提高性能。THandle(){}为构造函数。void cancel(){flag_=true;}提高接口来设置取消功能,调用cancel则将flag_设置为ture表明取消任务。bool isCancel()const{return flag_;}为构建查询语句,调用者可以查询当前是否已经取消了。Among them, Class THandle{ is to create a THandle class to encapsulate the canceled function and data. atomic<bool>flag_{false}; the member variable has only one flag_ variable. In this embodiment, the atomic variable is used, and the bool type can be used to express two states of cancellation and non-cancellation. At the same time, because the flag_ variable will give To access the underlying encryption algorithm, the underlying layer is multi-threaded access, and the caller object-c may also use asynchronous threads to cancel, the traditional scheme may use the locking scheme, and the use of atomic variables can avoid multi-threaded locking. Improve performance. THandle(){} is the constructor. void cancel(){flag_=true;} Improve the interface to set the cancel function, and call cancel to set flag_ to true to indicate the cancellation of the task. bool isCancel() const{return flag_;} is used to construct a query statement, and the caller can query whether it has been canceled currently.

在此实施例中调用者可以通过封装后的接口发出调用加解密取消任务的指令,并能够通过查询接口获得取消任务没有取消是否成功的事件回执,从而感知到取消任务的执行状态。且传递的是接口对象,而不是把整个加密任务都返回给调用者,目的是减少调用者对加密任务的细节的感知,从而减少其对加密任务的操控,将其需要的最小的粒度的数据给到调用者,减少出错的可能性。In this embodiment, the caller can issue an instruction to call the encryption/decryption cancellation task through the encapsulated interface, and can obtain the event receipt of whether the cancellation task is successful or not through the query interface, so as to perceive the execution status of the cancellation task. And the interface object is passed, instead of returning the entire encryption task to the caller, the purpose is to reduce the caller's perception of the details of the encryption task, thereby reducing its manipulation of the encryption task, and the smallest granularity data it needs. to the caller, reducing the possibility of errors.

步骤S130、创建包装类,并对所述封装类进行包装,使不同程序语言架构下的调用函数持有同一份封装类的传递对象,实现不同程序语言之间传递对象的互相调用。Step S130 , creating a wrapper class, and wrapping the wrapper class, so that calling functions under different programming language architectures hold a transfer object of the same wrapper class, so as to realize mutual calling of transfer objects between different programming languages.

本实施例的设计是基于ojbect-c和c++之间进行互相调用,并且ojbectc的调用者和c++内部加解密具体执行者生命周期是不一样的,双方的对对象的管理也是不一样的。因此不想将过多的取消实现细节暴露给调用者。如果直接将THandle返回给调用者,则会存在handle对象既被调用者所持有,也被c++底层所持有,所以直接返回handle则会存在问题,因此本实施例采弱引用通常用于解决循环依赖的问题。The design of this embodiment is based on mutual calls between ojbect-c and c++, and the life cycle of the caller of ojbectc and the specific executor of internal encryption and decryption of c++ are different, and the management of objects by both parties is also different. So don't want to expose too many de-implementation details to the caller. If THandle is directly returned to the caller, the handle object will be held by both the caller and the underlying layer of C++, so there will be problems when returning the handle directly. Therefore, the weak reference in this embodiment is usually used to solve the problem. Circular dependency problem.

如图2所示,具体的解决方案如下:As shown in Figure 2, the specific solutions are as follows:

步骤S131、定义成员变量,建立不控制对象生命周期的弱引用智能指针,所述弱引用智能指针持有所述封装类,将所述封装类内的传递对象作为管理对象;Step S131, define a member variable, establish a weak reference smart pointer that does not control the life cycle of the object, the weak reference smart pointer holds the encapsulation class, and the transfer object in the encapsulation class is used as a management object;

步骤S132、构造赋值函数,对封装类内的传递对象赋值得到赋值对象,并且建立参数将所述赋值对象传入弱引用智能指针。Step S132 , constructing an assignment function, assigning a value to the transfer object in the encapsulation class to obtain an assignment object, and establishing parameters to transfer the assignment object to the weak reference smart pointer.

具体的说,创建包装类的程序语言的设计如下:Specifically, the programming language for creating wrapper classes is designed as follows:

class TWrapHandleclass TWrapHandle

weak_ptr<THandle>handler_;weak_ptr<THandle>handler_;

TWrapHandle(weak_ptr<THandle>handler):TWrapHandle(weak_ptr<THandle>handler):

handler_(handler){}handler_(handler){}

bool cancel(){if(auto ptr=handler_.lock())bool cancel(){if(auto ptr=handler_.lock())

ptr->cancel();return true;ptr->cancel(); return true;

else{return false;}else{return false;}

bool isCancel()const{bool isCancel()const{

,if(auto ptr=handler_.lock()),if(auto ptr=handler_.lock())

{returnptr->isCancel();{returnptr->isCancel();

Else{return false;}Else{return false;}

其中,创建class TWrapHandle{作为包装类来对THandle进行包装,并使用弱引用的方式。成员变量:weak_ptr<THandle>handler_;成员变量使用了weak_ptr(智能指针)来持有一个THandle。构造函数:TWrapHandle(weak_ptr<THandle>handler):handler_(handler){},利用构造函数来对handler_进行赋值,并且需要参数传入一个weak_ptr<THandle>(智能指针)的对象。Among them, create class TWrapHandle{ as a wrapper class to wrap THandle and use weak reference. Member variable: weak_ptr<THandle>handler_; member variable uses weak_ptr (smart pointer) to hold a THandle. Constructor: TWrapHandle(weak_ptr<THandle>handler):handler_(handler){}, use the constructor to assign a value to handler_, and need to pass in a weak_ptr<THandle> (smart pointer) object as a parameter.

本实施例采用弱引用的方式解决ojbect-c和c++之间相互持有一个对象的情况,解决即使C++释放了对象THandle,ojbect-c层的继续访问THandle时不会由于THandle释放了而导致程序崩溃,THandle释放则取消是不成功的,同时调用者持有的是一个弱引用底层c++库如果在进行加解密任务时,如果释放了,而调用者持有的是弱引用,从而可以避免程序崩溃。This embodiment adopts the method of weak reference to solve the situation that ojbect-c and C++ hold an object with each other, and solves that even if C++ releases the object THandle, the ojbect-c layer will not cause program damage due to the release of THandle when it continues to access the THandle. Crash, the cancellation of THandle release is unsuccessful, and the caller holds a weak reference to the underlying C++ library. If it is released when performing encryption and decryption tasks, and the caller holds a weak reference, the program can be avoided. collapse.

在另一实施例中,拷贝构造函数和赋值构造函数不能定义成私有的,必须使用系统默认的公开的,即TWrapHandle(const TWrapHandle&handle)和TWrapHandle(TWrapHandle&handle)和赋值构造函数TWrapHandle&operator=(constTWrapHandle&a)这3个函数保持是系统自动生成的,以使不同调用对象均能获得拷贝韩式和赋值函数。In another embodiment, the copy constructor and assignment constructor cannot be defined as private, and the system default public ones must be used, namely TWrapHandle(const TWrapHandle&handle) and TWrapHandle(TWrapHandle&handle) and the assignment constructor TWrapHandle&operator=(constTWrapHandle&a) these 3 This function remains automatically generated by the system, so that different calling objects can obtain copy and assignment functions.

在另一实施例中,还包括传递对象查询功能,以查询取消任务是否被另一对象执行或完成。In another embodiment, a pass object query function is also included to query whether the cancellation task was performed or completed by another object.

步骤S133、建立取消接口,通过所述弱引用智能指针检测所传递对象否被C++层释放,若没有被释放,执行取消任务;Step S133, establishing a cancellation interface, and detecting whether the passed object is released by the C++ layer through the weak reference smart pointer, and if it is not released, execute the cancellation task;

建立查询取消接口,通过所述弱引用智能指针检测所述传递对象时否被C++层释放,若没有被释放,执行查询取消任务,A query cancellation interface is established, and the weak reference smart pointer is used to detect whether the passed object is released by the C++ layer. If it is not released, the query cancellation task is executed.

具体的说,实现取消接口查询功能的程序语言如下:Specifically, the programming language that implements the cancel interface query function is as follows:

bool cancel(){if(auto ptr=handler_.lock());bool cancel(){if(auto ptr=handler_.lock());

ptr->cancel();ptr->cancel();

return true;return true;

else{return false;}else{return false;}

其中,bool cancel(){if(auto ptr=handler_.lock())为取消接口;需要先判断handler_对象是否还有效,是否被c++所释放了,如果没有被释放则执行取消,否则不执行。ptr->cancel();此处则是调用THandle的接口cancel来取消,返回return true。else{return false;}如果对象释放了则不取消,返回false,说明加解密任务已经完成或者销毁了,不需要取消。Among them, bool cancel(){if(auto ptr=handler_.lock()) is the cancellation interface; it is necessary to first determine whether the handler_ object is still valid and whether it has been released by c++. If it is not released, the cancellation will be executed, otherwise it will not be executed. . ptr->cancel(); here is to call the interface cancel of THandle to cancel and return return true. else{return false;} If the object is released, it will not be canceled, and return false, indicating that the encryption and decryption task has been completed or destroyed, and no cancellation is required.

实现查询取消功能的程序语言如下:The programming language that implements the query cancellation function is as follows:

bool isCancel()const{bool isCancel()const{

if(auto ptr=handler_.lock())if(auto ptr=handler_.lock())

{returnptr->isCancel();{returnptr->isCancel();

Else{return false;}Else{return false;}

其中,bool isCancel()const为查询取消接口;此处只是查询所以使用const修饰,同样的需要判断handler_对象是否还有效,if(auto ptr=handler_.lock()){returnptr->isCancel();调用THandle的接口isCancel来判断是否已经取消了Else{return false;}如果没有被释放则执行取消,否则不执行,如果对象释放了则不取消,返回false。说明加解密任务已经完成或者销毁了,不需要取消。Among them, bool isCancel()const is the query cancellation interface; here is only query so use const modification, also need to judge whether the handler_ object is still valid, if(auto ptr=handler_.lock()){returnptr->isCancel() ;Call the interface isCancel of THandle to judge whether Else has been canceled {return false;} If it has not been released, it will be canceled, otherwise it will not be executed. If the object is released, it will not be canceled and return false. It means that the encryption and decryption task has been completed or destroyed, and does not need to be cancelled.

本实施例中,使用封装层对传递对象进行封装,可以比较程序崩溃,也可不使用封装层,其实现过程如下:In this embodiment, using the encapsulation layer to encapsulate the transfer object can compare the program crash or not use the encapsulation layer. The implementation process is as follows:

ojbect-c则需要自己持有weak_ptr<THandle>handler对象,并且在调用取消和判断是否取消时,需要刻意的去调用if(auto ptr=handler_.lock())来判断handler是否已经销毁了,丙炔判断交由ojbect-c的使用者来判断和维护,由并不是C++层的开发者,很容易造成疏忽或者忘记了判断,从而会导致程序crash。ojbect-c needs to hold the weak_ptr<THandle>handler object by itself, and when calling cancel and judging whether to cancel, it needs to call if(auto ptr=handler_.lock()) deliberately to judge whether the handler has been destroyed, C The alkyne judgment is handed over to the users of ojbect-c to judge and maintain. The developers who are not the C++ layer can easily cause negligence or forget the judgment, which will cause the program to crash.

因此本实施例设计了一层封装(TWrapHandle)层来将具体的细节封装到c++层,对ojbect-c的使用者是透明的,调用者也不需要关心也不可能疏忽对handler_的判断而造成程序crash。Therefore, in this embodiment, a layer of encapsulation (TWrapHandle) is designed to encapsulate the specific details into the C++ layer, which is transparent to the user of ojbect-c, and the caller does not need to care and cannot ignore the judgment of handler_. Cause the program to crash.

在另一实施例中,当调用者通过取消命令接口和/或查询命令接口提出加解密取消任务请求时,C++层返回一个取消任务的对象句柄,进而调用对应的任务回调接口,执行取消功能。In another embodiment, when the caller requests encryption and decryption to cancel the task through the cancel command interface and/or the query command interface, the C++ layer returns an object handle of the cancel task, and then calls the corresponding task callback interface to execute the cancel function.

具体的说,设计c++层返回任务取消的对象句柄如下:Specifically, the C++ layer is designed to return the object handle of the task cancellation as follows:

ojbect-c调用了一个加解密任务后,C++层可以返回一个取消任务的对象句柄,从而其可以调用取消任务。在C++层底层则是提供数据加解密的功能。其封装在类encryptCore中,其核心数据和接口设计如下:After ojbect-c calls an encryption and decryption task, the C++ layer can return an object handle to cancel the task, so that it can call the cancel task. The bottom layer of the C++ layer provides the function of data encryption and decryption. It is encapsulated in the class encryptCore, and its core data and interface are designed as follows:

Class encryptCore{Class encryptCore{

shared_ptr<THandle>handler_;shared_ptr<THandle>handler_;

TWrapHandle encrypt(void*data);TWrapHandle encrypt(void*data);

handler_=make_shared<THandle>();handler_=make_shared<THandle>();

Retun TWrapHandle(handler_);}Retun TWrapHandle(handler_); }

其中,Class encryptCore{为核心数据接口,shared_ptr<THandle>handler_;为成员变量,需要使用shared_ptr来持有THandle,意思是encryptCore负责THandle对象的创建和销毁,维护其生命周期。Among them, Class encryptCore{ is the core data interface, shared_ptr<THandle>handler_; is a member variable, you need to use shared_ptr to hold the THandle, which means that encryptCore is responsible for the creation and destruction of the THandle object and maintains its life cycle.

TWrapHandle encrypt(void*data)为加解密接口,此接口核心的是需要创建THandle并创建TWrapHandle,并返回给object-c一个TWrapHandle对象。首先是对象的创建handler_=make_shared<THandle>()即创建一个THandle的共享指针;RetunTWrapHandle(handler_);}并且return一个TWrapHandle对象。TWrapHandle encrypt(void*data) is an encryption and decryption interface. The core of this interface is to create a THandle and create a TWrapHandle, and return a TWrapHandle object to object-c. The first is the creation of the object handler_=make_shared<THandle>(), that is, to create a shared pointer of THandle; RetunTWrapHandle(handler_);} and return a TWrapHandle object.

作为一种优选,在本实施例中需要返回使用对象的拷贝操作,不能够返回TWrapHandle的指针,那么调用者objectc则会拷贝此对象TWrapHandle,其持有的TWrapHandle对象由于不是指针则会自动超出生命周期后自动释放。这样object-c可以随意的拷贝TWrapHandle对象,同时也不需要担心TWrapHandle对象的生命周期,任务取消的对象的THandle生命周期,使用了weak_ptr<THandle>来持有一份对象的引用。并且c++和ojbect-c必须使用同一份THandle的对象。ojbect-c持有的weak_ptr<THandle>不会造成c++无法释放shared_ptr<THandle>对象的情况,所以双方互相不进行依赖。作为一种优选,执行取消任务或查询取消任务时,需要在C++层设置加密和解密任务,具体过程如下:As a preference, in this embodiment, the copy operation of the used object needs to be returned, and the pointer of TWrapHandle cannot be returned, then the caller objectc will copy the object TWrapHandle, and the TWrapHandle object it holds will automatically exceed the life span because it is not a pointer Automatic release after cycle. In this way, object-c can copy the TWrapHandle object at will, and at the same time, it does not need to worry about the life cycle of the TWrapHandle object. The THandle life cycle of the object whose task is cancelled uses weak_ptr<THandle> to hold a reference to the object. And c++ and ojbect-c must use the same THandle object. The weak_ptr<THandle> held by ojbect-c will not cause C++ to fail to release the shared_ptr<THandle> object, so the two parties do not depend on each other. As a preference, when executing the cancellation task or querying the cancellation task, the encryption and decryption tasks need to be set at the C++ layer. The specific process is as follows:

由于每个事件点都是一个功能函数,需要在执行具体功能时检查下其是否已经被取消了,从而就可以不必执行功能函数,同时函数的执行过程中是没有办法强制取消的,所以可以在其执行完成后再次检查是否是取消的任务,同时避免任务执行完成了先回调了任务的完成事件联起来,具体的语言程序如下:Since each event point is a function function, it is necessary to check whether it has been cancelled when executing the specific function, so that the function function does not need to be executed. At the same time, there is no way to force cancellation during the execution of the function, so you can After its execution is completed, it checks again whether it is a canceled task, and at the same time avoids the completion of the task execution and the completion of the callback task. The specific language program is as follows:

ClassAutoCheck{ClassAutoCheck{

TWrapHandle handle_;TWrapHandle handle_;

status status_;status status_;

Callback callback_;Callback callback_;

AutoCheck(TWrapHandle thandle,status status,Callback callback):handle_(handle),status_(status),callback_(callback){If(handler_->isCancel())callback_->OnCancel(status_);}AutoCheck(TWrapHandle thandle, status status, Callback callback): handle_(handle), status_(status), callback_(callback) {If(handler_->isCancel())callback_->OnCancel(status_);}

其中,~AutoCheck(){为定义复核类,If(handler_->isCancel())callback_->OnCancel(status_);}为任务是否被取消,ClassAutoCheck{Among them, ~AutoCheck(){ is the definition review class, If(handler_->isCancel())callback_->OnCancel(status_);} is whether the task is canceled, ClassAutoCheck{

TWrapHandle handle_;将封装类内的传递对象定义为复核类的成员变量;statusstatus_;成员变量记录当前的状态allback callback_;为回调对象。AutoCheck(TWrapHandle thandle,status status,Callback callback):handle_(handle),status_(status),callback_(callback){If(handler_->isCancel())callback_->OnCancel(status_);}复核的成员变量包括封装类、包装类、状态码和回调对象,定义条件语句~AutoCheck(){If(handler_->isCancel())callback_->OnCancel(status_);}如果传递对象任务是否被取消,如果是返回对应的阶段状态。TWrapHandle handle_; Define the passed object in the encapsulation class as a member variable of the review class; statusstatus_; The member variable records the current status callback callback_; is the callback object. AutoCheck(TWrapHandle thandle, status status, Callback callback): handle_(handle), status_(status), callback_(callback){If(handler_->isCancel())callback_->OnCancel(status_);}The member variables of the review include Encapsulation class, wrapper class, status code and callback object, define conditional statement ~ AutoCheck(){If(handler_->isCancel())callback_->OnCancel(status_);} If the passed object task is canceled, if it is, return the corresponding stage status.

复核类保障了每个功能函数开始和结束都会检测当前任务是否有取消。取消事件必须是在其任务执行完后执行,检查则必须是在功能函数头和函数尾,设计一个对象构造函数检测析构函数再次检测,可以避免开发者忘记了检查或者只在函数头检测没有在函数尾检测,The review class ensures that the start and end of each function function will detect whether the current task has been canceled. The cancellation event must be executed after its task is executed, and the check must be at the head and tail of the function function. Design an object constructor to check the destructor and check again, which can prevent developers from forgetting to check or only checking in the function header. Check at the end of the function,

核心数据和接口的设计的程序语言为:The programming languages for the design of core data and interfaces are:

Class encryptCore{。Class encryptCore{.

status status_;status status_;

Void Prepare(){Void Prepare(){

status_=Prepare;status_=Prepare;

AutoCheck auto(handler_,status_,callback_);AutoCheck auto(handler_, status_, callback_);

If(handler_->isCancel())If(handler_->isCancel())

callback_->OnCancel(status_);callback_->OnCancel(status_);

ElseElse

Void key(){Void key(){

status_=key;status_=key;

AutoCheck auto(handler_,status_,callback_);AutoCheck auto(handler_, status_, callback_);

If(handler_->isCancel()){callback_->OnCancel(status_);}If(handler_->isCancel()){callback_->OnCancel(status_);}

Else{继续准备key的数据}Else{Continue to prepare key data}

Void Sucess(){Void Sucess(){

If(handler_->isCancel()){callback_->OnCancel(Cancel);}If(handler_->isCancel()){callback_->OnCancel(Cancel);}

status_=Sucess;status_=Sucess;

callback_->OnSucess(status_);callback_->OnSucess(status_);

Or callback_->OnError(status_);Or callback_->OnError(status_);

}}

其中,Class encryptCore{加解密类会持有callback对象,并且其会基于上述的各个status来完成数据的加解密功能,并且需要判断当前的任务是否有取消。成员变量:Callback callback_持有一份object-c实现的Callback子类,object-c需要基于定义的各个接口来实现加解密任务的回调功能。具体就是实现各个接口的功能,成员变量:statusstatus_;当前加解密的状态。成员函数:Void Prepare(){status_=Prepare;为赋值状态变量。AutoCheck auto(handler_,status_,callback_);内部会检测下面的任务取消。If(handler_->isCancel())首先检查加解密任务是否有取消。如果取消了,直接回调任务取消功能。callback_->OnCancel(status_);并传入取消时所处于的状态status_,从而调用者object-c知道任务取消是在那个状态取消的。Else{继续完成数据准备的功能。}成员函数:Among them, Class encryptCore{The encryption and decryption class will hold the callback object, and it will complete the data encryption and decryption function based on the above status, and it is necessary to judge whether the current task has been cancelled. Member variable: Callback callback_ holds a Callback subclass implemented by object-c. Object-c needs to implement the callback function of encryption and decryption tasks based on the defined interfaces. Specifically, it implements the functions of each interface, member variables: statusstatus_; the current state of encryption and decryption. Member function: Void Prepare(){status_=Prepare; is the assignment state variable. AutoCheck auto(handler_,status_,callback_); The following task cancellation will be detected internally. If(handler_->isCancel()) first checks whether the encryption and decryption tasks are canceled. If it is canceled, it will directly call back the task cancel function. callback_->OnCancel(status_); and pass in the status status_ in which it was canceled, so that the caller object-c knows that the task cancellation was canceled in that state. Else{Continue to complete the function of data preparation. } member function:

Void key(){status_=key;首先赋值状态变量。AutoCheck auto(handler_,status_,callback_)内部检测任务取消。If(handler_->isCancel()){callback_->OnCancel(status_);}Else{继续准备key的数据}同样的对于其他几个状态的判断都和上面是一样的,而需要单独的对于Suces和Erro需要单独的进行改造。Void key(){status_=key; first assign the status variable. AutoCheck auto(handler_, status_, callback_) Internal detection task cancellation. If(handler_->isCancel()){callback_->OnCancel(status_);}Else{Continue to prepare key data} Similarly, the judgments for several other states are the same as above, but separate Suces and Erro needs to be retrofitted separately.

成员函数Void Sucess(){和Error的实现是一样的。在完成回调前必须对任务的取消功能进行检测,如果是需要取消,此时不能将状态设置为Sucess,而必须设置为Cancel,否则会造成任务的错位。If(handler_->isCancel()){callback_->OnCancel(Cancel);}而只有当前任务不是取消时,才能确定回调任务的成功或者失败。status_=Sucess;callback_->OnSucess(status_);或者是callback_->OnError(status_);}在加解密任务已经完成时,为object-c的任务发送了取消功能,本实施例的设计防止了object-c产生任务的错位,将任务状态改成取消,并且取消了任务完成的回调。The implementation of the member function Void Sucess(){ and Error is the same. Before completing the callback, the cancellation function of the task must be detected. If it needs to be canceled, the status cannot be set to Sucess at this time, but must be set to Cancel, otherwise the task will be dislocated. If(handler_->isCancel()){callback_->OnCancel(Cancel);} and only when the current task is not canceled, can the success or failure of the callback task be determined. status_=Sucess; callback_->OnSucess(status_); or callback_->OnError(status_);} When the encryption and decryption task has been completed, the cancel function is sent for the task of object-c, and the design of this embodiment prevents the object -c generates a dislocation of the task, changes the task status to cancel, and cancels the callback of the task completion.

在另一实施例中,为使代码在两种语言中混合调用,本发明还设计ios的ojbect-c层的逻辑。In another embodiment, the present invention also designs the logic of the ojbect-c layer of ios in order to make the code call mixed in the two languages.

在ojbect-c层,需要存储调用encryptCore的encrypt接口返回的TWrapHandle对象,而在其实现代码中,需要将文件设置为.mm的文件格式,表示其会使用objectc和c++的混调用,而头文件还是使用.h,但是.h文件中不存储TWrapHandle成员,而是将其放到.mm中进行存储,不对外暴露出TWrapHandle的存在,而只在.h文件中暴露一个取消的接口,从而其他ojbect-c在使用取消功能时,不需要知道TWrapHandle成员的存在,从而其他ojbect-c可以使用.m来编写,如果一旦将TWrapHandle存放到了.h文件中,那么所有的ojbect-c代码都必须使用.mm的形式,从而对ojbect-c造成了破坏。In the ojbect-c layer, the TWrapHandle object returned by calling the encrypt interface of encryptCore needs to be stored, and in its implementation code, the file needs to be set to the .mm file format, which means that it will use the mixed call of objectc and c++, and the header file .h is still used, but the TWrapHandle member is not stored in the .h file, but is stored in .mm, and the existence of TWrapHandle is not exposed to the outside world, but only a canceled interface is exposed in the .h file, so that other When ojbect-c uses the cancel function, it does not need to know the existence of the TWrapHandle member, so other ojbect-c can use .m to write, if once the TWrapHandle is stored in the .h file, then all ojbect-c code must use .mm form, thus wreaking havoc on ojbect-c.

在本实施例中,设计ios的ojbect-c层的逻辑,可以保证代码在两种语言中混合调用,避免应用层出错。In this embodiment, the logic of the ojbect-c layer of ios is designed to ensure that the codes are mixed in two languages and to avoid errors in the application layer.

上面对本申请实施例中设置iOS平台下加解密任务取消的方法进行了描述,下面对本申请实施例中的具有iOS平台下加解密任务取消功能的装置进行描述。The method for setting the cancellation of the encryption and decryption task under the iOS platform in the embodiment of the present application has been described above, and the device with the function of canceling the encryption and decryption task under the iOS platform in the embodiment of the present application is described below.

如图3所示,本发明实施例中还提供了一种具有iOS平台下加解密任务取消功能的装置的一个实施例,该装置包括:功能模块210、封装模块220和包装模块230。As shown in FIG. 3 , an embodiment of the present invention also provides an embodiment of an apparatus having an encryption/decryption task cancellation function under the iOS platform. The apparatus includes: a function module 210 , a packaging module 220 and a packaging module 230 .

功能模块210用于创建包括加解密任务请求回调接口的任务类,并在回调接口内创建表示加解密任务执行结果和任务状态的参数,以实现各回调接口的功能;封装模块220用于创建具有状态变量的封装类,能够在调用者发布加解密任务请求时,向调用者返还状态变量,封装类内包含有传递接口,以向调用者提供了任务取消的功能和数据;包装模块230用于创建包装类,包装类使用弱引用的方式对封装类进行包装并返回调用者一个包括封装类的成员变量对象,使不同程序语言架构下的调用函数持有同一份封装类成员变量对象,实现不同程序语言之间封装类对象的互相调用。The function module 210 is used to create a task class including the encryption and decryption task request callback interface, and create parameters representing the encryption and decryption task execution result and task status in the callback interface, so as to realize the function of each callback interface; the encapsulation module 220 is used to create a The encapsulation class of the state variable can return the state variable to the caller when the caller issues an encryption/decryption task request. The encapsulation class contains a transfer interface to provide the caller with the function and data of task cancellation; the packaging module 230 is used for Create a wrapper class. The wrapper class uses a weak reference to wrap the wrapper class and returns a member variable object including the wrapper class to the caller, so that calling functions under different programming language architectures hold the same member variable object of the wrapper class to achieve different implementations. The mutual call of encapsulated class objects between programming languages.

在另一实施例中,包装模块230包括:获取单元231和判断单元232,获取单元231用于定义成员变量,建立不控制对象生命周期的智能指针,智能指针持有封装类,并利用构造函数对封装类内的传递接口赋值,并且建立参数将传递接口传入智能指针,作为管理对象。判断单元232用于判断包含取消功能传递接口对象和/或包含查询取消功能的传递接口对象是否被第C++层释放。In another embodiment, the packaging module 230 includes: an obtaining unit 231 and a judging unit 232, the obtaining unit 231 is used to define member variables, establish a smart pointer that does not control the life cycle of the object, the smart pointer holds the package class, and uses the constructor function Assign a value to the transfer interface in the encapsulation class, and establish parameters to pass the transfer interface into the smart pointer as a management object. The judging unit 232 is configured to judge whether the delivery interface object containing the cancellation function and/or the delivery interface object containing the query cancellation function is released by the C++ layer.

作为一种优选,在另一实施例中,功能模块210包括显示单元211,能够显示封装类内包含的传递接口,以向调用者提供任务取消的功能和数据。As a preferred embodiment, in another embodiment, the function module 210 includes a display unit 211 capable of displaying the transfer interface contained in the encapsulation class, so as to provide the caller with the function and data of task cancellation.

上面图3从模块化功能实体的角度对本申请实施例中的具有iOS平台下加解密任务取消功能的装置进行了描述,下面从硬件处理的角度对本申请实施例中的具有iOS平台下加解密任务取消功能的装置装置进行详细描述,请参阅图4,本申请实施例中的推荐具有iOS平台下加解密任务取消功能的装置300为一个实施例,包括:Figure 3 above describes the device with the encryption and decryption task cancellation function under the iOS platform in the embodiment of the present application from the perspective of a modular functional entity, and the following describes the encryption and decryption task under the iOS platform in the embodiment of the present application from the perspective of hardware processing. The device with the cancellation function is described in detail, please refer to FIG. 4 , the device 300 recommended to have the function of canceling the encryption and decryption task under the iOS platform in the embodiment of the present application is an embodiment, including:

输入装置301、输出装置302、处理器303和存储器304(其中处理器303的数量可以一个或多个,图3中以一个处理器303为例)。在本申请的一些实施例中,输入装置301、输出装置502、处理器303和存储器304可通过总线或其它方式连接,其中,图3中以通过总线连接为例。An input device 301, an output device 302, a processor 303, and a memory 304 (wherein the number of processors 303 may be one or more, and one processor 303 is taken as an example in FIG. 3). In some embodiments of the present application, the input device 301 , the output device 502 , the processor 303 , and the memory 304 may be connected by a bus or in other ways, wherein the connection by a bus is taken as an example in FIG. 3 .

其中,通过调用存储器304存储的操作指令,处理器303,用于执行如下步骤:Wherein, by calling the operation instructions stored in the memory 304, the processor 303 is used to perform the following steps:

创建包括加解密任务请求回调接口的任务类,以实现加解密任务的取消;Create a task class including the encryption and decryption task request callback interface to cancel the encryption and decryption task;

创建具有状态变量的封装类,封装类内包含有传递对象,以向调用者提供任务取消命令接口和/或数据接口;Create an encapsulation class with state variables, and the encapsulation class contains a transfer object to provide the caller with a task cancellation command interface and/or data interface;

创建包装类,并对封装类进行包装,使不同程序语言架构下的调用函数持有同一份封装类的传递对象,实现不同程序语言之间传递对象的互相调用。Create a wrapper class, and wrap the wrapper class, so that the calling functions under different programming language architectures hold the same transfer object of the wrapper class, and realize the mutual call of the transfer objects between different programming languages.

通过调用存储器304存储的操作指令,处理器303,还用于执行图1和图2对应的实施例中的任一方式。By invoking the operation instructions stored in the memory 304, the processor 303 is further configured to execute any manner in the embodiments corresponding to FIG. 1 and FIG. 2 .

如图5所示,为本申请实施例提供的电子设备的实施例示意图。As shown in FIG. 5 , it is a schematic diagram of an embodiment of an electronic device provided in an embodiment of the present application.

在另一实施例中,本发明还提供了一种电子设备,包括存储器410、处理器420及存储在存储器420上并可在处理器420上运行的计算机程序411,处理器420执行计算机程序411时实现以下步骤。In another embodiment, the present invention also provides an electronic device, comprising a memory 410, a processor 420, and a computer program 411 stored on the memory 420 and executable on the processor 420, and the processor 420 executes the computer program 411 implement the following steps.

创建包括加解密任务请求回调接口的任务类,以实现加解密任务的取消;Create a task class including the encryption and decryption task request callback interface to cancel the encryption and decryption task;

创建具有状态变量的封装类,封装类内包含有传递对象,以向调用者提供任务取消命令接口和/或数据接口;Create an encapsulation class with state variables, and the encapsulation class contains a transfer object to provide the caller with a task cancellation command interface and/or data interface;

创建包装类,并对封装类进行包装,使不同程序语言架构下的调用函数持有同一份封装类的传递对象,实现不同程序语言之间传递对象的互相调用。Create a wrapper class, and wrap the wrapper class, so that the calling functions under different programming language architectures hold the same transfer object of the wrapper class, and realize the mutual call of the transfer objects between different programming languages.

在具体实施过程中,处理器420执行计算机程序411时,可以实现图1对应的实施例中任一实施方式。In a specific implementation process, when the processor 420 executes the computer program 411, any one of the implementation manners in the embodiments corresponding to FIG. 1 may be implemented.

由于本实施例所介绍的电子设备为实施本申请实施例中一种具有iOS平台下加解密任务取消功能的装置所采用的设备,故而基于本申请实施例中所介绍的方法,本领域所属技术人员能够了解本实施例的电子设备的具体实施方式以及其各种变化形式,所以在此对于该电子设备如何实现本申请实施例中的方法不再详细介绍,只要本领域所属技术人员实施本申请实施例中的方法所采用的设备,都属于本申请所欲保护的范围。Since the electronic device introduced in this embodiment is a device used to implement a device with an encryption/decryption task cancellation function under the iOS platform in the embodiment of this application, based on the method introduced in the embodiment of this application, the technology in this field belongs to the Personnel can understand the specific implementation of the electronic device in this embodiment and its various modifications, so how the electronic device implements the method in the embodiment of the present application will not be described in detail here, as long as those skilled in the art implement the present application The equipment used in the methods in the embodiments all belong to the scope of protection of the present application.

请参阅图6,图6为本申请实施例提供的一种计算机可读存储介质的实施例示意图。Please refer to FIG. 6, which is a schematic diagram of an embodiment of a computer-readable storage medium provided by an embodiment of the present application.

如图6所示,本实施例提供了一种计算机可读存储介质500,其上存储有计算机程序511,该计算机程序511被处理器执行时实现如下步骤:As shown in FIG. 6 , this embodiment provides a computer-readable storage medium 500 on which a computer program 511 is stored. When the computer program 511 is executed by a processor, the following steps are implemented:

创建包括加解密任务请求回调接口的任务类,以实现加解密任务的取消;Create a task class including the encryption and decryption task request callback interface to cancel the encryption and decryption task;

创建具有状态变量的封装类,封装类内包含有传递对象,以向调用者提供任务取消命令接口和/或数据接口;Create an encapsulation class with state variables, and the encapsulation class contains a transfer object to provide the caller with a task cancellation command interface and/or data interface;

创建包装类,并对封装类进行包装,使不同程序语言架构下的调用函数持有同一份封装类的传递对象,实现不同程序语言之间传递对象的互相调用Create a wrapper class, and wrap the wrapper class, so that the calling functions under different programming language architectures hold the same transfer object of the wrapper class, and realize the mutual call of the transfer objects between different programming languages.

在具体实施过程中,该计算机程序511被处理器执行时可以实现图1-2对应的实施例中任一实施方式。In a specific implementation process, when the computer program 511 is executed by the processor, any one of the embodiments corresponding to the embodiments shown in FIGS. 1-2 can be implemented.

需要说明的是,在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详细描述的部分,可以参见其它实施例的相关描述。It should be noted that, in the foregoing embodiments, the description of each embodiment has its own emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.

本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by those skilled in the art, the embodiments of the present application may be provided as a method, a system, or a computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.

本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式计算机或者其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded computer or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means implementing the functions specified in one or more of the flowcharts and/or one or more blocks of the block diagrams.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions The apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.

本申请实施例还提供了一种计算机程序产品,该计算机程序产品包括计算机软件指令,当计算机软件指令在处理设备上运行时,使得处理设备执行如图1-2对应实施例中的风电场数字化平台设计的方法中的流程。The embodiment of the present application also provides a computer program product, the computer program product includes computer software instructions, when the computer software instructions are executed on the processing device, the processing device is made to perform the wind farm digitization in the corresponding embodiment of FIG. 1-2. Process in the methodology of platform design.

所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(digital subscriber line,DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(solid state disk,SSD))等。The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer may be a general purpose computer, special purpose computer, computer network, or other programmable device. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be downloaded from a website site, computer, server, or data center Transmission to another website site, computer, server, or data center by wire (eg, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be stored by a computer, or a data storage device such as a server, data center, etc., which includes one or more available media integrated. The usable media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVDs), or semiconductor media (eg, solid state disks (SSDs)), and the like.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system, device and unit described above may refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.

在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.

所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(RandomAccess Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes.

以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。As mentioned above, the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand: The technical solutions described in the embodiments are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions in the embodiments of the present application.

Claims (10)

Translated fromChinese
1.一种iOS平台下加解密任务取消的方法,其特征在于,包括:1. a method for canceling encryption and decryption tasks under an iOS platform, is characterized in that, comprising:创建包括加解密任务请求回调接口的任务类,以实现加解密任务的取消;Create a task class including the encryption and decryption task request callback interface to cancel the encryption and decryption task;创建具有状态变量的封装类,所述封装类内包含有传递对象,以向调用者提供任务取消命令接口和/或数据接口;Create an encapsulation class with state variables, the encapsulation class contains a transfer object to provide the caller with a task cancellation command interface and/or a data interface;创建包装类,并对所述封装类进行包装,使不同程序语言架构下的调用函数持有同一份封装类的传递对象,实现不同程序语言之间传递对象的互相调用。A wrapper class is created, and the wrapper class is packaged, so that the calling functions under different programming language frameworks hold the same transfer object of the wrapper class, so as to realize the mutual calling of transfer objects between different programming languages.2.根据权利要求1所述的iOS平台下加解密任务取消的方法,其特征在于,所述任务类的创建过程包括:2. the method for cancellation of encryption and decryption task under the iOS platform according to claim 1, is characterized in that, the creation process of described task class comprises:在所述回调接口内创建表示加解密任务执行结果和任务状态的参数,以实现各回调接口的功能;Create parameters representing the execution result of the encryption/decryption task and the task status in the callback interface, so as to realize the function of each callback interface;其中,所述回调接口包括加解密执行成功的回调接口、加解密出错的回调接口和任务实际取消的回调接口;以及The callback interface includes a callback interface for successful encryption and decryption execution, a callback interface for encryption and decryption errors, and a callback interface for actually canceling the task; and创建所述任务状态参数的状态集合,所述状态集合内包含标记任务状态的状态码;Create a state set of the task state parameters, the state set contains a state code marking the task state;其中,所述状态码表示加解密任务执行结果和任务状态,并包括加解密任务准备中、生成加解密密钥中、加解密数据准备中、数据加密中、数据解密中、任务已经取消、任务成功和任务取消中的一种或多种。The status code represents the execution result and task status of the encryption and decryption task, and includes the encryption and decryption task in preparation, encryption and decryption key generation, encryption and decryption data preparation, data encryption, data decryption, task canceled, task One or more of success and task cancellation.3.根据权利要求1或2所述的iOS平台下加解密任务取消的方法,其特征在于,所述封装类的创建过程包括:3. the method for canceling encryption and decryption task under the iOS platform according to claim 1 and 2, is characterized in that, the creation process of described encapsulation class comprises:构造封装函数;Construct wrapper function;在所述封装类内设置取消命令接口,调用者通过所述取消命令接口实现加解密任务的取消;A cancellation command interface is set in the encapsulation class, and the caller realizes the cancellation of the encryption and decryption tasks through the cancellation command interface;并在所述封装类内设置查询取消接口,调用者通过所述所述查询取消命令接口,实现加解密任务的查询命令取消;And a query cancellation interface is set in the encapsulation class, and the caller realizes the cancellation of the query command of the encryption and decryption task through the query cancellation command interface;其中,所述取消命令接口内设置有状态变量,所述状态变量使用布尔型原子变量,并包括取消状态变量和不取消状态变量。Wherein, a state variable is set in the cancel command interface, and the state variable uses a Boolean atomic variable, and includes a cancel state variable and a non-cancel state variable.4.根据权利要求1或2所述的iOS平台下加解密任务取消的方法,其特征在于,所述包装类的创建过程包括:4. the method for cancellation of encryption and decryption task under the iOS platform according to claim 1 and 2, is characterized in that, the creation process of described wrapper class comprises:定义成员变量,建立不控制对象生命周期的弱引用智能指针,所述弱引用智能指针持有所述封装类,将所述封装类内的传递对象作为管理对象;Define a member variable, establish a weak reference smart pointer that does not control the life cycle of the object, the weak reference smart pointer holds the encapsulation class, and the transfer object in the encapsulation class is used as a management object;构造赋值函数,对封装类内的传递对象赋值得到赋值对象,并且建立参数将所述赋值对象传入弱引用智能指针;Constructing an assignment function, assigning a value to the transfer object in the encapsulation class to obtain an assignment object, and establishing a parameter to pass the assignment object into a weak reference smart pointer;建立取消接口,通过所述弱引用智能指针检测所传递对象否被C++层释放,若没有被释放,执行取消任务;Establish a cancellation interface, detect whether the passed object is released by the C++ layer through the weak reference smart pointer, and execute the cancellation task if it is not released;建立查询取消接口,通过所述弱引用智能指针检测所述传递对象时否被C++层释放,若没有被释放,执行查询取消任务。A query cancellation interface is established, and whether the passed object is released by the C++ layer is detected through the weak reference smart pointer, and if it is not released, the query cancellation task is performed.5.根据权利要求4所述的iOS平台下加解密任务取消的方法,其特征在于,还包括:5. the method for cancellation of encryption and decryption task under the iOS platform according to claim 4, is characterized in that, also comprises:当调用者通过取消命令接口和/或查询取消命令接口提出加解密任务取消请求时,C++层返回一个取消任务对象句柄,进而调用对应的任务回调接口,执行取消功能。When the caller makes an encryption/decryption task cancellation request through the cancel command interface and/or the query cancel command interface, the C++ layer returns a cancel task object handle, and then calls the corresponding task callback interface to execute the cancel function.6.根据权利要求5所述的iOS平台下加解密任务取消的方法,其特征在于,所述C++层取消任务对象句柄的接口构建过程包括:6. the method for cancellation of encryption and decryption task under the iOS platform according to claim 5, is characterized in that, the interface construction process that described C++ layer cancels task object handle comprises:建立引用计数型智能指针,所述引用计数型智能指针持有所述封装类内的传递对象,能够对所述传递对象创建和销毁;establishing a reference counting smart pointer, the reference counting smart pointer holds the transfer object in the encapsulation class, and can create and destroy the transfer object;建立所述封装类的共享指针,并返回调用者一个对应的弱引用智能指针的管理对象;establishing the shared pointer of the encapsulation class, and returning a corresponding weak reference smart pointer management object to the caller;其中,所述弱引用智能指针的管理对象返回调用者时,采用拷贝操作返回,使C++层和调用者使用同一份传递对象。Wherein, when the management object of the weak reference smart pointer is returned to the caller, a copy operation is used to return, so that the C++ layer and the caller use the same transfer object.7.根据权利要求6所述的iOS平台下加解密任务取消的方法,其特征在于,还包括加解密任务取消状态参数的检查复核,其通过以下步骤实现:7. the method for cancellation of encryption and decryption task under the iOS platform according to claim 6, is characterized in that, also comprises the inspection and review of encryption and decryption task cancellation state parameter, and it realizes through the following steps:建立复核类,并将所述解密任务取消的传递对象、所述解密任务取消对应的状态和任务回调对象作为成员变量;A review class is established, and the transfer object of the cancellation of the decryption task, the state corresponding to the cancellation of the decryption task, and the task callback object are used as member variables;建立对象构造函数,检测所述解密任务取消的传递对象是否内部取消;establishing an object constructor to detect whether the transfer object canceled by the decryption task is canceled internally;若取消,回调任务取消,传入对用的状态参数,并告知调用者。If it is canceled, the callback task is canceled, the corresponding state parameter is passed in, and the caller is notified.8.一种具有iOS平台下加解密任务取消功能的装置,其特征在于,包括:8. a device with encryption and decryption task cancellation function under iOS platform, is characterized in that, comprises:功能模块,其用于创建包括加解密任务请求回调接口的任务类,以实现加解密任务的取消;A function module, which is used to create a task class including an encryption and decryption task request callback interface, so as to realize the cancellation of the encryption and decryption task;封装模块,其用于创建具有状态变量的封装类,所述封装类内包含有传递对象,以向调用者提供任务取消接口和/或数据接口;an encapsulation module, which is used to create an encapsulation class with state variables, the encapsulation class contains a transfer object to provide a caller with a task cancellation interface and/or a data interface;包装模块,并对所述封装类进行包装,使不同程序语言架构下的调用函数持有同一份封装类的传递对象,实现不同程序语言之间封装类传递对象的互相调用。The packaging module wraps the encapsulation class, so that the calling functions under different programming language frameworks hold the same encapsulation class transfer object, and realizes the mutual call of the encapsulation class transfer objects between different programming languages.9.一种电子设备,包括应用处理器和存储器,其特征在于,所述处理器用于实现所述存储器中存储得计算机管理程序式时实现如权利要求1-7中任一项所述的iOS平台下加解密任务取消方法的步骤。9. An electronic device, comprising an application processor and a memory, wherein the processor is used to implement the iOS as described in any one of claims 1-7 when the processor is used to implement a computer management program stored in the memory The steps of the encryption and decryption task cancellation method under the platform.10.一种计算机可读存储介质,其上存储有计算机管理类程序,其特征在于,所述计算机管理类程序被处理器执行时实现如权利要求1-7中任意一项所述的iOS平台下加解密任务取消的方法的步骤。10. A computer-readable storage medium on which a computer management class program is stored, wherein the computer management class program implements the iOS platform according to any one of claims 1-7 when the computer management class program is executed by a processor The steps of the method for canceling the encryption and decryption tasks are as follows.
CN202011185235.4A2020-10-292020-10-29 A method for canceling encryption and decryption tasks under the iOS platform and related equipmentPendingCN114428687A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202011185235.4ACN114428687A (en)2020-10-292020-10-29 A method for canceling encryption and decryption tasks under the iOS platform and related equipment

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202011185235.4ACN114428687A (en)2020-10-292020-10-29 A method for canceling encryption and decryption tasks under the iOS platform and related equipment

Publications (1)

Publication NumberPublication Date
CN114428687Atrue CN114428687A (en)2022-05-03

Family

ID=81309292

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202011185235.4APendingCN114428687A (en)2020-10-292020-10-29 A method for canceling encryption and decryption tasks under the iOS platform and related equipment

Country Status (1)

CountryLink
CN (1)CN114428687A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN107368377A (en)*2017-06-302017-11-21武汉斗鱼网络科技有限公司Network request processing method and processing device in a kind of Android application programs
CN108696537A (en)*2018-07-092018-10-23武汉斗鱼网络科技有限公司Long connection network data distribution and processing method and system in IOS systems
CN109976831A (en)*2019-03-282019-07-05山东浪潮通软信息科技有限公司Data interactive method between a kind of JavaScript and primary APP
CN110968147A (en)*2018-09-302020-04-07武汉斗鱼网络科技有限公司Timer creating method and device, electronic equipment and medium
CN111092916A (en)*2018-10-232020-05-01武汉斗鱼网络科技有限公司File uploading method and device, electronic equipment and medium
CN111176626A (en)*2019-08-052020-05-19腾讯科技(深圳)有限公司Cross-programming-language code calling method and device, medium and equipment
US20200195601A1 (en)*2018-12-182020-06-18Leavemark, Inc.Asynchronous messaging and communication in a social networking system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN107368377A (en)*2017-06-302017-11-21武汉斗鱼网络科技有限公司Network request processing method and processing device in a kind of Android application programs
CN108696537A (en)*2018-07-092018-10-23武汉斗鱼网络科技有限公司Long connection network data distribution and processing method and system in IOS systems
CN110968147A (en)*2018-09-302020-04-07武汉斗鱼网络科技有限公司Timer creating method and device, electronic equipment and medium
CN111092916A (en)*2018-10-232020-05-01武汉斗鱼网络科技有限公司File uploading method and device, electronic equipment and medium
US20200195601A1 (en)*2018-12-182020-06-18Leavemark, Inc.Asynchronous messaging and communication in a social networking system
CN109976831A (en)*2019-03-282019-07-05山东浪潮通软信息科技有限公司Data interactive method between a kind of JavaScript and primary APP
CN111176626A (en)*2019-08-052020-05-19腾讯科技(深圳)有限公司Cross-programming-language code calling method and device, medium and equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
马华杰;袁永军;谭悦;王建勇;: "CLIPS与Visual C++接口的研究", 仪器仪表用户, no. 06, 8 December 2005 (2005-12-08)*

Similar Documents

PublicationPublication DateTitle
JP6092249B2 (en) Virtual channel for embedded process communication
TWI533204B (en)Method and system for application execution in a restricted application execution environment, and computer-readable storage medium for recording related instructions thereon
US20170103192A1 (en)Secure code delivery
WO2018201895A1 (en)Interface code generation method, apparatus, terminal device and medium
US9158935B2 (en)Automatic mediation of resource access in mobile applications
WO2016033966A1 (en)Protection method and device for application data
CN106295370A (en)A kind of method and apparatus of the dynamic link library (DLL) file reinforcing installation kit
CN110083342A (en)A kind of program creating method, device and computer readable storage medium
WO2023232052A1 (en)Method for processing remote certification report, and database server and database client
CN111859226A (en) A page jumping method, device and related equipment
CN109725887B (en)Data interaction method and device based on message research and development framework and terminal equipment
CN104360869B (en)Method for preventing underlying driver from intercepting messages
CN103246514A (en)Method for implementing exception framework on the basis of cloud computing
CN114327404B (en) A file processing method, device, electronic device and computer readable medium
CN114428687A (en) A method for canceling encryption and decryption tasks under the iOS platform and related equipment
EP3188071A1 (en)Application accessing control method and device
CN109254856A (en)Intelligent POS server-side provides interface to the method for client
CN111198899B (en)Development system and method for entity rendering in application program
CN113127928B (en)Database data access method and device, electronic equipment and medium
CN116010112B (en)Method and device for calling hook function, computer equipment and readable storage medium
CN114665882B (en) A decompression method and device based on multiple data compression algorithms
JP4810846B2 (en) Programs that prevent unauthorized use of program data
CN117369865A (en)GNU linux universal application program packaging method and graphical application packer
CN112486424B (en)User transparent arithmetic core parallel printing order-preserving proxy method
JP2011204105A (en)Script activation program, generation program of the same and program set

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp