To achieve the purpose of controlling a group of fibers through an event (the state of the event object is of type bool)
Event object constructor
1new Event(Boolean value = false);
- value: Boolean, specify whether to wait, wait when true, the default is false
Determine whether the event object is true
- Boolean, If the event is true, return true
Activate the event (change the event status to true) and call pulse()
Activate all fibers waiting for the event
Reset event (change event status to false)
Waiting for an event
Acquire ownership of the lock
1Boolean Event.acquire(Boolean blocking = true);
- blocking: Boolean, specify whether to wait, if it is true, wait, the default is true
- Boolean, Returns whether the lock is successfully acquired, true means the acquisition is successful
The acquire method is used to acquire the ownership of the lock. When the lock is in an acquireable state, this method returns true immediately.
When the lock is unavailable and blocking is true, the current fiber goes to sleep. When other fibers release the lock, this method returns true.
When the lock is not available and blocking is false, the method returns false.
Release lock ownership
This method will release the ownership of the lock. If the current fiber does not own the lock, this method will throw an error.
Query the number of currently waiting tasks
- Integer, Returns the number of tasks
Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics
- String, Returns the string representation of the object
Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object
1Value Event.toJSON(String key = "");
- key: String, unused
- Value, Returns a value containing JSON serializable