diskwizz 24 Posted February 13, 2015 Report Share Posted February 13, 2015 (edited) Threading is always new and exciting. Your bots become quicker, they can process more data in a shorter time and they can handle more things at once. This has truly increased the power with which we can design and improve software. But as always great power comes with great responsibility. The main problem with threading is that multiple threads would like to write or read from the same resources at once. Resources in this case would be a #variable, %list, or a &table. But if two threads write to the same resource at the same time the resources will become corrupted or in the worst case scenario your apps will crash.This however can be easily solved with thread protection in this case the "Lock" and the "System Wide Lock" command that comes with the Communication Plugin. Locks protect a part of code being accessed by two or more threads at the same time, so that we will not experience corrupted data or the bot crashes. http://i.imgur.com/VzFN2dF.png?1 All the commands inside the lock will be protected from being run simultaneously and there for will be thread safe.http://i.imgur.com/ACTbvT9.png?1 Here we see a define that is not thread safe, if accessed by two threads at a time the data will become corrupted and/or the bot will crash. So how do we make this thread safe?Below we can see that "append to file" is inside a thread container and is thus thread safe.http://i.imgur.com/EMOgBkc.png?1The reason it's thread safe is because only one thread at a time is allowed to access the code inside the container and all other have to wait untill the current thread is finished. The waitng will most of the time just take a few miliseconds but it insures us the resources will be protected from corruption.The same method can be used for a #variable, %list, or a &table to ensure you don't have strange behavior where data becomes missing and things sync out of place. http://i.imgur.com/WNisa6M.png?1The lock name is used to identify the lock and the same lock name can be used throughout the code. So as soon as another lock with the same name gets accessed all other locks will also close and open if the thread has done it's work inside the lock. The lock will only exist inside the bot itself, all other application won't be aware of the lock unless you use "system wide lock".http://i.imgur.com/uMD1tXA.png?1 The "system wide lock" can be shared between bots. For example to bots can in this way write to the same file safely without the possibility that the data becomes corrupted. But be aware the lock names used must be identical in both bots! Plugin required: Communication Plugin Edited February 13, 2015 by diskwizz 3 Quote Link to post Share on other sites
Pete 121 Posted February 13, 2015 Report Share Posted February 13, 2015 Nice I take it this will also work with Ubots db commands Quote Link to post Share on other sites
diskwizz 24 Posted February 13, 2015 Author Report Share Posted February 13, 2015 Nice I take it this will also work with Ubots db commandsIt works with all commands! Quote Link to post Share on other sites
Bliss 194 Posted February 13, 2015 Report Share Posted February 13, 2015 Excellent Tutorial again! Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted February 15, 2015 Report Share Posted February 15, 2015 Very nice indeed. 1 Quote Link to post Share on other sites
heopas 90 Posted October 26, 2015 Report Share Posted October 26, 2015 Communication plugin isn' t for sale anymore. So you should find a new way... Quote Link to post Share on other sites
juicehunter 30 Posted October 26, 2015 Report Share Posted October 26, 2015 It's not available anymore no, but it was already available in Open.Framework.dll (link: https://mega.nz/#!lgRlibLI) Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted October 26, 2015 Report Share Posted October 26, 2015 communication plugin was bought out by myself, chris and danhttp://network.ubotstudio.com/forum/index.php/topic/18041-sell-exbrowser-now-on-sale/ Quote Link to post Share on other sites
juicehunter 30 Posted October 26, 2015 Report Share Posted October 26, 2015 communication plugin was bought out by myself, chris and danhttp://network.ubotstudio.com/forum/index.php/topic/18041-sell-exbrowser-now-on-sale/But it lacks the features he is asking for. Quote Link to post Share on other sites
luis carlos 94 Posted October 26, 2015 Report Share Posted October 26, 2015 It's not available anymore no, but it was already available in Open.Framework.dll (link: https://mega.nz/#!lgRlibLI)The link asks for a key. Quote Link to post Share on other sites
juicehunter 30 Posted October 26, 2015 Report Share Posted October 26, 2015 The link asks for a key. Oops, there you go https://mega.nz/#!lgRlibLI!l1vLHSqjngeQQ48H-W3u8ssgnnAWNNtqY73qbE8CuxU 2 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.