Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upNetwork, Execute fixes & FileIO #26
Conversation
Frotty
reviewed
Jan 6, 2018
I still need to test it in ebr, but looks sweet so far |
function getCurrentCallback() returns ForForceCallback | ||
return tempCallbacks[tempCallbacksCount - 1] | ||
|
||
/** | ||
This function starts a new 'thread' inside the |
This comment has been minimized.
This comment has been minimized.
Frotty
Jan 6, 2018
Member
I think instead of resetting the oplimit the newly created thread simply starts at zero.
Other important points to illustrate would be the difference between a timer/doAfter (the thread that starts the execute waits for it to be finished) and why we use ForForce instead of TriggerEvaluate.
tempCallbacksCount++ | ||
|
||
function popCallback() | ||
tempCallbacksCount-- | ||
destroy tempCallbacks[tempCallbacksCount] | ||
|
||
function getCurrentCallbackSuccess() returns boolean |
This comment has been minimized.
This comment has been minimized.
public function execute(ForForceCallback c) | ||
pushCallback(c) | ||
executeForce.forEach(function executeCurrentCallback) | ||
let success = getCurrentCallbackSuccess() |
This comment has been minimized.
This comment has been minimized.
interface LimitedExecuteAction | ||
function run() | ||
|
||
public function limitedExecuteInternal(int iterations, LimitedExecuteCondition condition, LimitedExecuteAction action) |
This comment has been minimized.
This comment has been minimized.
Frotty
Jan 6, 2018
Member
I'm not really happy with the name. Limited to me implies that it is more "limited" compared to the normal execute. But in actuality it does more than the normal execute.
I think something like Periodic, Sequential or Batch - Execute would be more intuitive.
popCallback() | ||
|
||
interface LimitedExecuteCondition | ||
function check() returns boolean |
This comment has been minimized.
This comment has been minimized.
Frotty
Jan 6, 2018
Member
The problem i see with the condition is that it doesn't have access to the iteration variable i which you might want to base your condition on instead of providing a fixed amount.
Maybe provide 1 execute that takes iterations and action, and one that only takes condition and action, where the condition will also check the iteration count by receiving it as parameter.
This comment has been minimized.
This comment has been minimized.
SamuelMoriarty
Jan 13, 2018
Author
Contributor
The 'iterations' here is a completely internal variable that is used to reset the OP limit when iteration count is exhausted. This value can't be used to control the outer loop, because it gets reset to 0 each iterations
times.
Without a condition
, this function will simply loop forever. The condition is used to break the loop.
for executor in TimedIOTaskExecutor | ||
executor.update() | ||
|
||
// called when an executor instance has started working |
This comment has been minimized.
This comment has been minimized.
lastExecution = currentTime | ||
if finished | ||
runningCount-- | ||
// stop the timer if necessary |
This comment has been minimized.
This comment has been minimized.
|
||
construct(player owner) | ||
this.owner = owner | ||
store = new PersistentStore(this, owner) |
This comment has been minimized.
This comment has been minimized.
protected function getPath() returns string | ||
return PERSISTABLE_MAP_PREFIX + "/" + getClassId() + "/" + getId() | ||
|
||
/* You must implement these */ |
This comment has been minimized.
This comment has been minimized.
buffer.populateFromFile(reader) | ||
buffer.transfer(network.getData()) | ||
// if there was an error during transfer, we scrap the data... | ||
if not buffer.isGood() |
This comment has been minimized.
This comment has been minimized.
SamuelMoriarty
force-pushed the
SamuelMoriarty:persistence
branch
from
b151787
to
85a2798
Jan 13, 2018
Cokemonkey11
reviewed
Jan 15, 2018
if lookup[i] == this | ||
value = i | ||
break | ||
return value |
This comment has been minimized.
This comment has been minimized.
Cokemonkey11
reviewed
Jan 15, 2018
function executeWhileInternal(int resetCount, LimitedExecuteCondition condition, LimitedExecuteAction action) | ||
execute(() -> begin | ||
var i = 0 | ||
// iterate as many times as needed |
This comment has been minimized.
This comment has been minimized.
Cokemonkey11
reviewed
Jan 15, 2018
@@ -565,16 +579,33 @@ public class StringBuffer extends AbstractBuffer | |||
checkRead() | |||
return checkType(ValueType.BOOLEAN) ? (popString(1) == "1") : false | |||
|
|||
override function clear() | |||
for chunk in chunks | |||
destroy chunk |
This comment has been minimized.
This comment has been minimized.
Cokemonkey11
reviewed
Jan 15, 2018
If multiMode is true, then path should be the path to a folder where the data will be stored. | ||
Otherwise, the path should be a file path. | ||
|
||
Delay is the number of seconds to wait between each file write operation. You should use |
This comment has been minimized.
This comment has been minimized.
Cokemonkey11
reviewed
Jan 15, 2018
You should override this to prevent conflicts with other maps using this class. | ||
**/ | ||
@configurable | ||
constant PERSISTABLE_MAP_PREFIX = "persistent" |
This comment has been minimized.
This comment has been minimized.
Cokemonkey11
reviewed
Jan 15, 2018
/** Maximum amount of packets per single readable file. */ | ||
public constant PACKETS_PER_FILE = 16 | ||
/** Maximum payload size of a single readable packet. */ | ||
public constant MAX_PACKET_LENGTH = 209 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Overall this is pretty brilliant. I think it's the biggest PR on stdlib. I hope Frotty has a backup of this code in case something happens. As it stands, the code quaility is very high and I think you've balanced perfection and pragmatism well. The nature of this stuff is fragile, though. There's necessarily a lot of non-generic type stuff here, bit twiddling, magic values, data reinterpretation, etc. I think that's fine. My final opinion is that this could go two ways:
I'll let you and Frotty decide which of these variants is the right one. In any case, please someone get a backup, and also thanks again, this is really, really cool |
This comment has been minimized.
This comment has been minimized.
I agree. I think it could be in stdlib to promote easy persistable data. e: Just as a reminder to @SamuelMoriarty the missing features we talked about;
|
Frotty
assigned
Frotty and
Cokemonkey11
Jan 17, 2018
SamuelMoriarty
added some commits
Dec 18, 2017
SamuelMoriarty
added some commits
Dec 23, 2017
SamuelMoriarty
force-pushed the
SamuelMoriarty:persistence
branch
from
85a2798
to
4c19903
Jan 29, 2018
SamuelMoriarty
force-pushed the
SamuelMoriarty:persistence
branch
from
e2c1718
to
eae5e73
Jan 29, 2018
Frotty
reviewed
Jan 29, 2018
@@ -8,10 +8,16 @@ import GameTimer | |||
import MagicFunctions | |||
import Hashtable | |||
|
|||
constant MUTE_ERROR_DURATION = 60 | |||
constant MUTE_ERROR_DURATION = 5 |
This comment has been minimized.
This comment has been minimized.
Frotty
Jan 29, 2018
Member
I don't think this is a good idea. Should probably make the value @configurable though
This comment has been minimized.
This comment has been minimized.
thanks a lot |
SamuelMoriarty commentedJan 3, 2018
No description provided.